簡體   English   中英

在 Kendo UI Grid 上獲取行數

[英]Getting row count on a Kendo UI Grid

我在 kedno tabstrip 的第二個選項卡中有一個 Kend UI 網格,我需要在其中獲取行數。 為此,我使用

/**
 * 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();    
}

根據 gird 對象的控制台日志,我有嵌套的 dataSource 對象和 _total 屬性,其中包含行數值,但 total() 始終返回 0

試試這個功能:

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

避免使用以下划線開頭的屬性,它可能用於其他目的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM