1

I have a jqGrid that is used to display a relativity large number of rows so I have pagination enabled to only fetch 100 at a time. I also have funcitonality that allows the user to add a new row to the grid. There is a requirement that after adding a row, that the row should be selected and visible in the grid.

I am currently using setSelection to select the row by id and this works if the row is on the current page. However, if the row is not on the current page, nothing happens. Does anyone have a suggestion on how I might implement this functionality?

zaq
  • 2,571
  • 3
  • 31
  • 39

1 Answers1

1

jqGrid only loads data for rows for the current page. See this question for some more background.

One possible solution is for you to add your row, and then make a request to the server to calculate the row's page. Then you can use the code from this answer to go to that page and select the row. You code might be similar to:

grid = $("#grid");
grid.setGridParam({page: myPage});
grid.trigger("reloadGrid");
grid.setSelection(myRow);

Does that help?

Community
  • 1
  • 1
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284