How to select a row in a kendo grid by data item id?

I need to select a specific row in kendoGrid, but NOT using data-uid (since data-uid changes when the grid data source is loaded again), but using the row identifier. I saw the messages, but they only select the line by uid, which is not what I need, I really need to restart the HTML5 application and when the grid is loaded, I need to select a specific element. This is what I saw

Demo: jsfiddle.net/rusev/qvKRk/3/

eg. the object has OrderID as ID , and every time the grid is loaded, it will be the same, unlike uid , I want to know how I can select a row with OrderID instead of uid .

+6
source share
3 answers

the work that I succeeded in was to go through all the lines and check which line model has this identifier equal to the parameter, and then get this uid data file and select the element via data-uid. It works great for me, since there were no assumptions, this is the best answer so far.

0
source

I think you will buy the string itemID and data.uid.

 var grid = $("#Grid").data("kendoGrid"); var dataItem = $("#Grid").data("kendoGrid").dataSource.get(itemID); var row = $("#Grid").data("kendoGrid").tbody.find("tr[data-uid='" + dataItem.uid + "']"); 
+16
source

According to what umais mentioned, the best approach, since there are currently no built-in functions for this, would have to iterate over all the entries to find the one you need. The function I built will work even if there are data pages. The only way I can think of this is to make ajax secondary call; But it works well. Please note that I have not tested it with more than 2000 entries.

  var dataGrid = $("#GATIPS").data("kendoGrid").dataSource; var numOfRows = dataGrid.total(); var currentPageSize = dataGrid.pageSize(); dataGrid.pageSize(numOfRows); var dataGridData = dataGrid.data(); for (var i = 0; i < numOfRows; i++) { if (dataGridData[i].uid == e) return dataGridData[i]; } dataGrid.pageSize(currentPageSize); // reset the view 

e is the UID. However, this can be replaced by what you only need for a replacement.

0
source

Source: https://habr.com/ru/post/949798/


All Articles