Removing Kendo Grid row not firing transport nor parameterMap.

2 posts, 0 answers
  1. Bartlomiej
    Bartlomiej avatar
    6 posts
    Member since:
    Feb 2016

    Posted 31 Aug 2018 Link to this post

    Clicking grid remove row fire grid datasource change event, but firing paramatermap and no remote transport is running. I can fire parameterMap by call .sync method in change event but this not passing removed data there, but only remaining rows data.

     

    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: " ", 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,
       })
     }
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 04 Sep 2018 Link to this post

    Hi Bartlomiej,

    The parameterMap and transport actions will be fired when submitting the changes to the server. When using batch edit mode changes in the Grid will be performed on the client and submitted in bulk when saving. Clicking the delete button would remove the record from the Grid, however that change would not yet be persisted to the server.

    When the users click Save Changes button a request containing the modifications will be sent to the server. The same happens when calling sync() method - it will submit the changes to the server.


    Regards,
    Viktor Tachev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top