删除Kendo Grid行而不触发传输或parameterMap

时间:2018-08-31 12:11:37

标签: kendo-ui telerik kendo-grid

单击网格删除行触发网格数据源更改事件,但是触发参数映射并且没有远程传输正在运行。我可以通过在更改事件中调用.sync方法来触发parameterMap,但这不会在此处传递已删除的数据,而只会传递剩余的行数据。

 allUsersDataSource.fetch(function() {
    allUsers = allUsersDataSource.data();
  })

  var assignedUsersDataSource = new kendo.data.DataSource({
    // autoSync: true,
    transport: {
      read:{
        url: API_URL+"frank/getassignedusers/"+documentId,
        dataType: "json"
      },
      create: {
        type: "POST",
        url: API_URL+"frank/addusertodocument",
        dataType: "json"
      },
      update: {
        type: "POST",
        url: API_URL+"frank/editusertodocument",
        dataType: "json"
      },
      destroy:{
        type: "POST",
        url: API_URL+"frank/removeuserdocument",
        dataType: "json"
      },
      batch: true,
      parameterMap: function(data, operation) {
        console.log ("assignedUsersDataSource.parameterMap.!! data:", data);
        console.log ("assignedUsersDataSource.parameterMap.!! operation:", operation);
        if (operation === "destroy" ) {
          //..
        }
        if (operation === "create" && data.UserID) {
        //..
        }
      }
    },
    change: function(e) {
        console.log("assignedUsersDataSource.change: e.items  :: ", e.items  );
      if(e.action === "remove"){
        // assignedUsersDataSource.sync();
      }
      //edycja i wstawianie
      if(e.action === "itemchange"){
        // assignedUsersDataSource.sync();
      }
      // itemchange to zawiera
      if(e.action === "add"){
      //   assignedUsersDataSource.sync();
      }
    },
    pageSize: 4,
    schema: {
      model: {
        fields: {
          UserName: { editable: false, nullable: true },
          Surname: { editable: false, nullable: true },
          UserID: { field: "UserID", defaultValue: 1 },
          GroupName: { editable: false, nullable: true },
        }
      }
    }
  });

  var _grid = $("\#grid-single-user-groups").kendoGrid({
    dataSource: assignedUsersDataSource,
    filterable: true,
    scrollable: false,
    // toolbar: ["create", "save"],
    toolbar: ["create"],
    pageable: true,
    columns: [
      {
        field: "UserID", width: "100%",
        editor: userDropDownEditor,
        title: "Agent",
        template: function(userID) {
            for (var idx = 0, length = allUsers.length; idx < length; idx++) {
              if (allUsers[idx].UserNameID == userID.UserID) {
                return allUsers[idx].Login;
              }
            }
        }
      },
      { command: [ "destroy"], title: "&nbsp;", width: "250px" }
    ],
    editable: {mode: "incell"},
  });

  function userDropDownEditor(container, options) {
    $('<input data-bind="value:' + options.field + '"/>')
    .appendTo(container)
    .kendoDropDownList({
      dataTextField: "Login",
      dataValueField: "UserNameID",
      filter: "contains",
      dataSource: allUsersDataSource,
      valuePrimitive:true,
    })
  }

0 个答案:

没有答案
相关问题