简体   繁体   English

剑道网格如何捕捉单元格变化事件

[英]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?我如何在 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 事件时将事件处理程序附加到单元格

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"));

 });

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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