简体   繁体   中英

Kendo grid how to catch cell change event

I need to trigger the change event if i change text in predefined cell.

I need something like this:

{   field: "username",
    title : $translate.instant('USER_NAME'),
    onchange:function(value) {
      // HERE I NEED TO GET CHANGED TEXT
    }
},

How can i do it in Kendo UI?

Thanks for help.

Use the Datasource Parameter Map once you click update you can take the changed data and map it before its send to server

var dataSource = new kendo.data.DataSource({
  transport: {
    update: {
      url: "Test url",
      dataType: "json" 
    },
    parameterMap: function(data, type) {
      if (type == "update") {
         // data.models will have your updated Values 
        return { models: kendo.stringify(data.models) };

      }
    }
  }
});

Update

If you need to get the change event for cell attach a event handler to the cell if grid dataBound event

dataBound: function (e) {
    // index is what ever the column index you need
 $("#kgrid").find('table tr td:nth-child(index)').unbind("click").bind("click", function (e) {
          var dataItem = $("#kgrid").data("kendoGrid").dataItem($(this).closest("tr"));

 });

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM