Kendo Grid UI编辑了值,但未保存



当有人点击网格中的编辑按钮时,我想捕捉事件。我正在尝试调用OnEdit函数,它不起作用,对此有任何解决方案吗?


<script>    
 // When user clicks on edit button command I would like to call this function.
 function onEdit(e) {
   alert('onEdit');
  }
// Kendo grid code for populating the data from ajax call and edit function. 

这是填充所有事件和数据源的起点。

$(document).ready(function() {
    dataSource = new kendo.data.DataSource({
        transport: {
            update: {    // Update event
                type: "POST",
                url: BASE_URL + "admin/updatePublisher.htm",
                contentType: "application/json; charset=utf-8",
                dataType: "json"
                success: function (result) { // success will save the data
                    options.success(result);
                }
            },
            parameterMap: function(options, operation) {
                // Update is clicked or created this is place it will reach. 
            },
            batch: true,pageSize: 50,
            schema: {
                type: "json",
                model: {
                    id: "id",
                    fields: {
                        id: {
                            editable: false,nullable: true,type: "number"
                        }
                    }
               },
               data: "items"   // the items return from ajax
           }, 
      });  // end of datasource
      // Kendo UI
      $("#grid").kendoGrid({
          dataSource: dataSource,
          navigatable: true,
          pageable: true,           
          toolbar: [{ name: "create", text: "Add Publisher"}], // toolbar menu
          columns: [{field: "publisherName"},{ command: ["edit"], title: "Actions" }],
          editable: "inline"
      });
   });
</script>

我已经找到了问题的解决方案,希望它对某人有用。kendoGrid中的edit属性解决了我的问题。

     $("#grid").kendoGrid({
        dataSource: dataSource,
        navigatable: true,
        pageable: true,
        edit      : function (e) {
            // Write your code
          },            
        height: 550,         
        toolbar: [{ name: "create", text: "Add Creater"}],
        columns: [{
            field: "emailCreativeName",
            title: "Email Creater",
            width: "350px"
        },{ command: ["edit"], title: "Actions", width: "200px" }],
        editable: "inline"
    });

最新更新