How to get kendo grid data-item on row button click?

sw
sw
4 Points
2 Posts

I'm using Kendo jQuery UI and trying to get data item on button click where button is on each rows.

function onMybuttonClick(id) {
    row = $(this).closest("tr");
    grid = $("#OrgUserGridAD").data("kendoGrid");
    dataItem = grid.dataItem(row);
}

in data binding:

{
    field: "Action",
    template: function (dataItem) {
        return "<button type='button' class='btn btn - primary' onclick=\"onMybuttonClick('" + dataItem.id + "')\">My Button</button>";
    },
    width: 150
}
Views: 68
Total Answered: 1
Total Marked As Answer: 0
Posted On: 17-Jan-2023 06:16

Share:   fb twitter linkedin
Answers
beginer
beginer
314 Points
87 Posts
         

Try something like:

function onMybuttonClick(e) {
    row = $(this).closest("tr");
    grid = $("#OrgUserGridAD").data("kendoGrid");
    dataItem = grid.dataItem(row);
}

Use in data binding:

{
    field: "Action",
    template: function (dataItem) {
        return "<button type='button' class='btn btn - primary' >My Button</button>";
    },
    width: 150
}

Bind event as:

 grid.table.on("click", ".btn", onMybuttonClick);
Posted On: 17-Jan-2023 22:00
 Log In to Chat