views:

214

answers:

1

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?

+2  A: 

A quick and easy way to do this using the jqGrid API is to:

  • Call editRow (which will set focus to the edited row)
  • And then immediately call restoreRow (because you do not really want to edit the row)

Otherwise you should be able to use jQuery's focus function to set focus to the row, for example: jQuery("#" + row_id).focus() - but I have not tested this method, so YMMV.

Justin Ethier
Actually, I do want to edit the row so I'll just leave it in edit mode - works like a charm!
Loki Stormbringer