Is there a way to get the row data when the grid is grouped by a column. We can get the row as shown below but when we then try to get the data for the row by index it does not work correctly when the grid has a group by a column. If you remove the grouping we can get the data just fine.
var row = $('.selector').igGrid('selectedRow');
var
row = $('.selector').igGrid('selectedRow');
$('.selector').data('igGrid').dataSource.dataView()[row.index];
Hello Tammy,
Thank you for posting in our forums! The row index is not the same as your expected because the group rows are taken into account. The simplest workaround is to get all of the grid’s rows and exclude the group rows. Then you can find the index of the selected row in the array of “data” rows. And this will be the index that you will use to get the row from the data view. I prepared a small sample page that demonstrates my solution. Please let me know if this works for you!
I’m looking forward to your reply!
Kind regards, Petko Zhekov Software Engineer
Here we are looking for solution that gives us data for row selection for all below scenario
1.Normal grid
2.Grouped grid
3.Filtered grid
4.Grouped & filtered grid
Thanks!
MD
Hi guys,
Did you have the chance to review my sample and test it in your case? Is there anything specific about the case that you didn’t mention – like virtualization or paging enabled? The solution I proposed does not care about the grouping or filtering state of the grid. Indeed it gets the index from the grid but in your previous post you said that you get the record from the data view which has the same set of records and the same order like what is rendered in the grid.
If you don’t like this approach you can set the primaryKey option of the grid. Then the object that selectedRow returns will contain property called “id”. You can use this id as a parameter of the dataSource’s findRecordByKey API method to find the record in the whole data source. I looks like this:
var rowId = $('#grid1').igGrid('selectedRow').id, ds = $('#grid1').data('igGrid').dataSource; var record = ds.findRecordByKey(rowId);
I hope this helps!
I looked into your sample it works great for grouping. We have grid which has feature like filterable , grouping , paging server side etc. When I have filter & grouping enabled the above sample won't work. Unfortunately we don't have primary key as single column.
Hello Manish,
Please let me know if you need further assistance or if you have any questions.
I'm good for now.