bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
637 stars 291 forks source link

call function after selecting item from the plutoColumnType.select items list #934

Closed Mohamed-7018 closed 8 months ago

Mohamed-7018 commented 10 months ago

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.

Mohamed-7018 commented 10 months ago

935 is a pull request to add this feature, waiting for this pull request to be merged !.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 8 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.