开发者

How to count the number of rows in a jqGrid?

How do I count the number of rows in a jqGrid?

To clar开发者_C百科ify, there is not much data involved so the grid is pulling all of its data back from the server in a single query, instead of using pagination.


jQuery("#myGrid").jqGrid('getGridParam', 'records');

Update

Note there are two parameters to determine record count:

records

integer

Readonly property. Gives the number of records returned as a result of a query to the server.


reccount

integer

Readonly property. Determines the exact number of rows in the grid. Do not confuse this with records parameter. Although in many cases they may be equal, there are cases where they are not. For example, if you define rowNum to be 15, but the request to the server returns 20 records, the records parameter will be 20, but the reccount parameter will be 15 (the grid you will have 15 records and not 20).


$("#grid").getGridParam("reccount");

Readonly property. Returns integer. Determines the exact number of rows in the grid. (And not the number of records fetched).

More information here.


Here is the code I have so far. It seems like there should be a better way:

jQuery("#myGrid").getDataIDs().length;


How about this?

jQuery("#myGrid tr").length;

Actually, you can take that a step further with the optional context parameter.

jQuery("tr", "#myGrid").length;

Either one will search for every "tr" inside of "#myGrid". However, from my own testing, specifying the context parameter is usually faster.


jQuery("#myGrid").jqGrid('getGridParam', 'records');


You could try:

jQuery("#GridId").jqGrid('getDataIDs');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜