Skip to content

Conversation

@Mohamed-7018
Copy link

Adding onSelectedItem function that can be passed by the developer (later) .

The function[onItemSelected] is callback function, which is called when selecting an item from the items list.
in other words when selecting an item the [onItemSelected] function will be called immediately and it return [PlutoGridOnSelectedEvent] event, so you you can use it make decisions.

for example:
let's assume that i want to print a string base on the user's selction, if the user chooses programming I will print "Hello programmer", else I will print "Hello Developer". Bys using the onSelectedItem function we can do this using the following simple code:

   PlutoColumn(
      title: 'Role',
      field: 'role',
      type: PlutoColumnType.select(
        <String>[
          'Programmer',
          'Designer',
          'Owner',
        ],
        onItemSelected: (PlutoGridOnSelectedEvent event) {
          if (event.cell!.value == "Programmer") {
            print("Hello Programmer");
          } else {
            print("Hello Developer");
          }
        },
      ),
    ),

Actually we can use this function in many ways, for example to change other cells data based on the user selection and so many other scenarios.

Copy link

@darkstar0x714 darkstar0x714 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it worked and seem good for me

doonfrs added a commit to doonfrs/pluto_grid_plus that referenced this pull request Dec 7, 2023
@doonfrs
Copy link

doonfrs commented Dec 7, 2023

Merged here:
https://pub.dev/packages/pluto_grid_plus

bastaware pushed a commit to bastaware/pluto_grid that referenced this pull request Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants