Reputation: 2242
How can I calculate a grid's row count? My grid has data, but this code returns 0
:
alert($('#Grid').data("kendoGrid").tbody.find('>tr.k-master-row').length);
Upvotes: 1
Views: 1780
Reputation: 40887
First, one side note: finding the length of a grid
based on tbody
will show you only the number of rows in the view
(those visible) if there is paging
you will not know those not visible.
There are several options:
$("#grid").data('kendoGrid').tbody.find('>tr').length
$("#grid").data('kendoGrid').tbody[0].rows.length
dataSource.view
: grid.dataSource.view().length
Upvotes: 3
Reputation: 8275
As OnaBai says, it depends if you want the whole count of lines in the table or only the one visibles.
If you want the total number of lines, you can use :
$("#grid").data("kendoGrid").dataSource.total();
and if you only want the visible ones, you can use :
$("#grid").find("tbody > tr").length;
Upvotes: 2
Reputation: 780
Try this @flower
$("#grid").data('kendoGrid').tbody[0].rows.length
Demo: http://jsfiddle.net/SWnSs/1/
Upvotes: 0