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];
I'm good for now.
Hello Manish,
Please let me know if you need further assistance or if you have any questions.
Hi Manish,
Can you modify the grid in my sample to match your configuration and attach it back? It will help me give you a proper solution.
Kind regards, Petko Zhekov Software Engineer
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.
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!