I am trying to get the selected row index from iggrid with different pages in jquery.
When I have only single page then I am able to get value. But when i have multiple pages in grid then i am not able to get the records/values/index.
var grid = $(iggridid).igGrid("selectedRows");
I have selected 2 rows from page1 and page2. I get correct index value for page2 but I am getting -1 for page1.
When i have single page then below code works fine
Please help to get value or index of selected rows from iggrid with different pages.
Thank you for posting in our community.
The behavior that you are experiencing is expected. By design, when Paging is enabled the index correspond to the current visible index of the row. Since rows from pages, that are currently not in the view area do not have actual visible index their index is set to -1. If you would like to uniquely identify the rows and get reference to their cell values you can use the getCellValue ot getCellText methods. For example:
var selectedRows = $("#grid").igGrid("selectedRows"),
firstSelectedRowID = selectedRows.id,
cellValue = $("#grid").igGrid("getCellValue", 3, "col_key");
Additionally, please keep in mind if you select rows across different pages and Row Selectors feature is not enable you have to hit Ctrl key while you are making the selection to ensure that previously selected rows are not dissected.
Please test my suggestion on your side and let me know if you need any further assistance with this matter.
I have tried your samples as mentioned above.
The syntax firstSelectedRowID = selectedRows.id returns 10 digit value
how to consume it to get row value
selectedRows.id returns the primary key of your grid set via the primaryKey property. Depending on what you set for this option is what is going to be returned. Alternatively, if the primary key is not set to any particular column an auto generated id is created and this might be the reason why you are getting a 10 digit number returned. Please ensure that the primary key is set to a column of your choice and let me know if you need any further assistance with this matter.
As much as i know igGrid maintains only 0-9 row index value even for different pages in grid. This makes harder to get the selected rows when we want to select from different page.
What I want is I have igGrid with multiple pages and I will selected rows from different pages. I want the row index for those selected rows index value.
Kindly provide the source code for this. I have tried this for a week and getting delayed.
Please reply as soon as possible.