This is a migrated thread and some comments may be shown as answers.

Finding a particular row

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pinaki
Top achievements
Rank 1
Pinaki asked on 25 Feb 2013, 10:13 AM
Hello all.
I'm wondering if anyone can help me here.

There are 2 grids on a page. (For example).
On the first grid ('grid1') the databinding is in client side AJAX. The grid has paging, filtering, sorting, etc, the usual stuff.

On the second ('grid2') grid (set the same as above), I have an event for saveChanges() since the 2nd grid has batch update enabled.
On the client side javescript of the 2nd grid, I need to get a row with a particulat attribute from the first grid.
Say for e.g.  Get the row with dataFieldCode = "MyCode". Please note, dataFieldCode is NOT the unique ID or a primary key.
Moreover, I want the actual underlying data and not the view, since this row maybe on Page 3 of the first grid, but the user has not navigated to page 3.

So just getting the view() of the data does not work.

I could not find a single example, where you get a data item with a given attribute (like a find or a seek) and you are not seeking the DOM. I need the underlying dataitem.

Any help here please?

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 27 Feb 2013, 08:29 AM
Hi Pinaki,

 
Basically you can access the full data of the grid using the dataSource data method without parameters and iterate over it to find the required records - please check the example below: 

function findNodes() {
    var grid = $("#grid").data("kendoGrid");
    var gridData = grid.dataSource.data();
 
    var foundNodes = [];
    for (var i = 0; i < gridData.length; i++) {
        if (gridData[i].dataFieldCode == "MyCode") {
            foundNodes.push(gridData[i]);
        }
    }
    //the foundNodes array contains all nodes that satisfy the dataFieldCode == "MyCode" condition
}

Also to be able to access the records from other pages of the grid you should disable the serverPaging configuration option.
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Pinaki
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or