Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kendo grid How to get a row by field value

I need to get a row(s) from my kendo grid, using a string as parameter to filter rows. the grid model is:

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

i tried this, but isn't working:

 var grid = $("#kendoGrid").data("kendoGrid");
 var row = grid.tbody.find("tr[desc_tipo_pagamento=test]");
like image 923
pasluc74669 Avatar asked Oct 09 '13 16:10

pasluc74669


People also ask

How do I get column values in kendo grid?

You can get the cell value from the model of a grid. Option 1: $("#grid"). data("kendoGrid").

What is field in kendo grid?

field String. The field to which the column is bound. The value of this field is displayed in the column's cells during data binding. Only columns that are bound to a field can be sortable or filterable.


1 Answers

Instead of using DOM, I would suggest using jQuery.grep on the DataSource.data array (if you want all) or in DataSource.view if you want from the current visible ones.

Example:

// 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 will contain a reference to the records in DataSource that matched the condition.

like image 81
OnaBai Avatar answered Oct 11 '22 00:10

OnaBai