kendo grid如何按字段值获取行

pas*_*669 4 javascript kendo-ui kendo-grid

我需要从我的kendo网格中获取一行,使用字符串作为参数来过滤行.网格模型是:

{
    id: "id_tipo_pagamento",
    fields: {
        id_tipo_pagamento: { type: "number", editable: false },
        desc_tipo_pagamento: { type: "string"}
}
Run Code Online (Sandbox Code Playgroud)

我试过这个,但是没有用:

 var grid = $("#kendoGrid").data("kendoGrid");
 var row = grid.tbody.find("tr[desc_tipo_pagamento=test]");
Run Code Online (Sandbox Code Playgroud)

Ona*_*Bai 17

而不是使用DOM的,我会建议使用jQuery.grep的上DataSource.data阵列(如果你希望所有)或DataSource.view如果从当前可见的人想要的.

例:

// Retrieve all data from the DataSource
var data = grid.dataSource.data();
// Find those records that have desc_tipo_pagamento set to "test"
// and return them in `res` array
var res = $.grep(data, function (d) {
    return d.desc_tipo_pagamento == "test";
});
Run Code Online (Sandbox Code Playgroud)

res 将包含对DataSource中与条件匹配的记录的引用.