This is a migrated thread and some comments may be shown as answers.

Removing Kendo Grid row not firing transport nor parameterMap.

1 Answer 416 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bartlomiej
Top achievements
Rank 1
Bartlomiej asked on 31 Aug 2018, 12:10 PM

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,
   })
 }

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 04 Sep 2018, 07:02 AM
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.
Tags
Grid
Asked by
Bartlomiej
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or