Kendo Grid is not returning dataItem in the event

2019-06-05 00:42发布

问题:

My Kendo grid has inline editing, and data is bound through ajax.

I have tried different options like:

1)

var grid = $("#Grid").data("kendoGrid"); 
var row = $(this).closest("tr");
var rowIdx = $("tr", grid.tbody).index(row);
var item =grid.dataItem(row)

2)

var row = $(this).closest("tr");
var grid = $("#Grid").data("kendoGrid");
var item = grid.dataItem(row);

3)

var selectedItem = this.dataItem(this.select()); -- I can't use this because my client does not want single click selection or double click selection on row so this is ruled out

4)

var dataItem = this.dataItem($(e.currentTarget).closest("tr")); 

When I use $(this).dataItem($(e.currentTarget).closest('tr')), it is throwing the error "Object doesn't support property or method 'dataItem'"

Can you please let me know any other way to get data item from kendo grid

回答1:

 var cell = this.select();

 var dataItem = this.dataItem(cell[0].parentNode);

this is the code that finally worked for me. I am binding the datasource in Ajax() , and I edit with Inline edit mode. My event is onChange(). uffff