I'm trying to use the "rowById" function on a grid (with paging) with a primary key. If the Id that I am looking for is on the "current" page it finds it fine. But if it is on not on the current page it is not found. Is there a way to use "rowById" if I don't know which page the Id will be found on? I want to find the row and get the index from it so I can programmatically move to the correct page and then select that row by index and save the index off. The code I am using is simple - but doesn't work if the Id is on a different page than the current one.
var row = $(gridId).igGrid("rowById", 123);if (row) indexToSelect = row.index();
Yes I had tried this approach previously by using
var record = $(gridId).igGrid("findRecordByKey", rowToSelect.keyValue);
That returns me the row in the datasource properly, but I can't see any "index" there - am I missing it? Once I find the record in the datasource, how do I know what index it is in the datasource?
Hello Ryan,
Please note that with Paging enabled, only certain number of records as specified by the pageSize properly is rendered to the user. You can get specific record from the datasource, but you can't get its DOM element if it's not rendered yet.
If you want to know the correct page index where specific record is placed, you may find this record by primary key in the datasource and see its index which you should divide by the pageSize. The result will be the correct page index.
If I can provide you with further assistance, please let me know.
Regards,Tsanna