i'm trying to get the selected row data item, i was able to get the data item from the selected row using DOM
but when a grouping or filtering or sorting is applied the data is different,
Is there a way to know the selected row data ?
3 Answers, 1 is accepted
There are couple of viable approaches to obtain the selected data item(s):
1) The selected item is available in the selectionChange event handler - e.selectedRows contains a collection of the selected rows and each such object has a dataItem property, e.g.:
2) You can keep a collection of all selected item and provide a function that returns the whole data item to the selectedKeys option, e.g.:
I hope this helps.
The answer in finding the selected row in a grid where the state (filtering, sorting, grouping etc) has been set is to persist the state first. My use case is to use the grid as a navigation item, users drill down to entities from individual rows and then have an option to return to the grid from the details page. By setting the current state on the button used for the drill down and reloading it when the user returns to the grid page you can then select the correct page of the grid with sorting, grouping and filtering applied and highlight the appropriate row as selected. Is this what you are trying to do? If you are then I am only too happy to share some code.
In your grid when you make the select event, pass the id. My code is much more complex but the below should help you;
In the example above I am checking to see where the user came from and, if appropriate, loading values from local storage. Your key here is the line where we are pushing the selected id to the selectedIds array which is used for the [selectedKeys] property of the grid.
I know this is not exactly what you wanted but I hope it helps you along the way.