0

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

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105
Anton
  • 1,010
  • 10
  • 30

1 Answers1

3

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.

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105