Hi,
I have a grid bound to a local JSON array, when the user clicks on a row in the grid I use the selected index to access the JSON object and then perform an operation on it. However I can't seem to work out how to make this work when the grid is filtered as the index is the displayed index and not the index of the original data.
Am I missing something obvious?
Thanks
Hi Ian,
Alternatively you can set igGrid.localSchemaTransform to false and igGrid.findRecrodByKey will return the whole object from the data source.
Hope this helps,
Martin Pavlov
Infragistics, Inc.
hi Ian,
You could use the dataSource method findRecordByKey.
It accepts two parameters - the first one is the PK value and the second one is the dataSource.
The original dataSource is stored in $("#grid1").data("igGrid").dataSource._origDs.
Passing those parameters like:
$("#grid1").data("igGrid").findRecordByKey("1", $("#grid1").data("igGrid").dataSource._origDs)
should return the original json object.
Hope this helps.
Regards Lyubo
Thanks for the feedback, I couldn't quite get this to work but it gave me a clue as to where to look and I am getting close but not quite what I need.
This is what I have now:
$("#gridChannels").bind("iggridselectionrowselectionchanged", function (event, ui) => {
var rowKey = ui.owner.grid.dataSource.dataView()[ui.row.index].name;
this.selectedChannel = $("#gridChannels").igGrid("findRecordByKey",rowKey);
This is correctly returning an object but its not the original JSON object it looks like it only has the properties that I have added as columns to the grid.
Is this what you would expect?
If so then I will have to search my local JSON array to find the full object and thats what I was trying to avoid.
Ian
It will be better to use the primaryKey instead the index. Assuming you are using single row selection and grid called grid1, you can get the PK value by:
using: $("#grid1").data("igGrid").selectedRow().element.data().id, i.e - you can get the PK value from the TR data().id
After that you can use the framework method - findRecordByKey to find your json record with the PK value.
Here is a sample similar post about using the selection and findRecordByKey.
http://ko.infragistics.com/community/forums/p/74820/378237.aspx
Hope this helps. Regards Lyubo