How to programmatically select top row of JQGrid?

jqgrid, jquery, row, selection

Solution

Or, without using the jqGrid API, you should be able to retrieve the top row by navigating the DOM:

var top_rowid = $('#mygrid tbody:first-child tr:first').attr('id');

Problem

How does one programmatically select the top row of a JQGrid. I want to have the top row already selected when it is opened on the page. My grid is sorted by a descriptive column so the first row's id could be any number. I know the method to use I just don't know how to get the rowid for the top (first) row. The method is: ``` jQuery("#mygrid").setSelection(rowid, true); ```

Original source