如何计算网格的行数?我的网格有数据,但此代码返回0:
alert($('#Grid').data("kendoGrid").tbody.find('>tr.k-master-row').length);
首先,一个旁注:查找 grid基于的长度tbody将只显示(那些可见的)中的行数,view如果paging你不知道那些不可见的。
有几种选择:
$("#grid").data('kendoGrid').tbody.find('>tr').length$("#grid").data('kendoGrid').tbody[0].rows.lengthdataSource.view:grid.dataSource.view().lengthAs 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;