0

I have a kendo grid and I am trying to obtain a dataItem from a dataRow, but my dataItem is always null.

This is the code I am using:

var dataGrid = row.find(".k-grid").data("kendoGrid");

var uidValue = "b318f970-79ec-472e-818f-f0d5adb6b5f3";
var dataRow = dataGrid.tbody.find("tr[data-uid='" + uidValue + "']")[0];
                           
                            
var dataItem = dataGrid.dataItem(dataRow);
                           

For testing purposes I manually added the id that I know for sure exists in the DOM. What can be the cause of this issue? I do have to mention that this code is inside an ajax call.

gameloverr
  • 53
  • 1
  • 8
  • Make sure this code is running after render. Also the uids change each time you create the grid, so make sure that uid really exists – ezanker Jul 21 '23 at 16:20

1 Answers1

0

Have you tried the getByUid method? Sample code below:

var grid = $("#yourGridID").data("kendoGrid");
var dataSource = grid.dataSource;
var dataItem = dataSource.getByUid(uid);
G_P
  • 2,100
  • 3
  • 16
  • 18