简体   繁体   中英

Getting row count on a Kendo UI Grid

I've got a Kend UI grid inside a second tab of kedno tabstrip and I need to get number of rows in it. For this purposes I use

/**
 * Getting number of rows in grid by it's ID
 * @param {string} gridId ID of the Grid
 * @returns {number} number of rows
 */
function getGridRowsCountById(gridId) {
    var grid = $("#" + gridId).data("kendoGrid");

    console.log(grid);

    grid.dataSource.read();  

    return grid.dataSource.total();    
}

According to console log of gird object I've got nested dataSource object and _total property with number of rows value in it but total() always returns 0

Try this function instead:

function getGridRowsCountById(gridId) {
    return $("#" + gridId).data("kendoGrid").dataSource.data().length;
}

Avoid using properties started as underline, it is propably used for another purposes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM