I have a jqGrid on a page and users can click a button to add a new row. If there are already enough rows on the page to fill the visible portion of the grid the new row is added and a scroll bar appears but the user needs to scroll to see the new row.
Is there a way to do this programmatically?
A quick and easy way to do this using the jqGrid API is to:
editRow(which will set focus to the edited row)restoreRow(because you do not really want to edit the row)Otherwise you should be able to use jQuery’sfocusfunction to set focus to the row, for example:jQuery("#" + row_id).focus()– but I have not tested this method, so YMMV.Actually
focuswill not scroll the grid’s div. But you can use the following code to guarantee that the grid scrolls such that the row with a givenidis viewable: