How to find the last row in jqgrid

2019-03-05 11:46发布

问题:

Currently i'm working on the jqgrid, where i have to find out the last row and implement the ctrl down functionality. But currently i could not able to get the last row.

Needed some one help here.

Thanks in advance

回答1:

If the grid id is for example list then the following expression should return you the last row:

$("#list").find(">tbody>tr.jqgrow:last");

or

$("#list").find(">tbody>tr.jqgrow").filter(":last");

One more, event better, way to get the last row is the following

var rows = $("#list")[0].rows,
    lastRowDOM = rows[rows.length-1];

It uses the rows collection of DOM representation of <table>. The value $(lastRowDOM) will the same as $("#list").find(">tbody>tr.jqgrow").filter(":last").



回答2:

For 4.6.0 version above

$("#list tbody:first tr:nth-child(2)").attr('id');

For me working fine using 4.6.0 version



标签: jquery jqgrid