繁体   English   中英

kendo grid如何按字段值获取行

[英]kendo grid How to get a row by field value

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

{
    id: "id_tipo_pagamento",
    fields: {
        id_tipo_pagamento: { type: "number", editable: false },
        desc_tipo_pagamento: { type: "string"}
}

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

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

我建议不要使用DOM,而是建议在DataSource.data数组上使用jQuery.grep (如果你想要全部),或者如果你想从当前可见的DataSource.view中使用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";
});

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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