OData v4 - Don't use $batch

Hello everyone!

I was wondering, whether there is a possibility to have the ODataV4 adapter for KanBan NOT use $batch requests when updating items. It is only changing a single item at a time anyways, so I would like to not have to implement the $batch endpoint.

Thanks for any pointer!

Cheers,
Christoph

3 Replies

AP Arun Palaniyandi Syncfusion Team April 5, 2018 12:17 PM UTC

Dear Christoph,    
      
Thanks for contacting Syncfusion Support.   
   
By default, the Kanban will do batch request even for a single item changes (drag and drop or editing a card), but we can change Kanban manually not to use this $batch when updating items. This can be achieved by changing the batch request using our custom Adaptor. Please find the below code snippets for more reference.    
    
    
<script> 
    $(function () { 
        var customAdaptor = new ej.ODataV4Adaptor().extend({ // Extend odatav4Adaptor 
            batchRequest: function (dm, changes, e, query) { // extend the batchrequest of ODataV4Adaptor 
 
                if (changes.changed.length >= 1) { // check the condition for any actions. Here I have checked for whether the changed is happened or not?. Likewise check for added and deleted too. 
                 
                    var response = { 
                        changed: changes.changed, // get only the changed data 
                        action: "batch", 
                        table: e.url, 
                        key: e.key 
                    }; 
                } 
                
 
                return { 
                    type: "POST",  // Send “POST” request to the controller    
                    url: dm.dataSource.url,   // send url (“odata/orders”) into post request  and hence the $batch endpoint is removed  
                    contentType: "application/json; charset=utf-8", 
                    dataType: "json", 
                    data: JSON.stringify(response)    // response variable was passed to controller    
                }; 
            } 
        }); 
 
 
        var dataManager = ej.DataManager({ 
            url: "/odata/Orders",   // specify the odata controller  
            adaptor: new customAdaptor()  //specify custom Adaptor 
        }); 
 
 
        $("#Kanban").ejKanban( 
                    { 
                        dataSource: dataManager, 
                        columns: [ 
                            { headerText: "Backlog", key: "VINET" }, 
                            { headerText: "In Progress", key: "QUICK" }, 
 
                        ], 
                        keyField: "CustomerID", 
                        allowTitle: true, 
                        fields: { 
                            content: "ShipName", 
                            primaryKey: "ShipVia" 
                        }, 
                        allowEditing: true, 
                        allowAdding: true 
 
                    }); 
 
    }); 
     
</script> 
    
    
    
We have also shared a sample below for your reference.      
   
   
Please refer to the following UG link: https://help.syncfusion.com/js/datamanager/data-adaptors#custom-adaptor      
   
      
If the shared details and sample doesn’t meet your requirement or if we misunderstood your query means, please send us more information to help us provide an exact solution.       
       
      
Regards,      
Arun P.   




CH Christoph Herold April 5, 2018 04:46 PM UTC

Hi Arun!

Thank you for the elaborate answer. I'm not sure, this is really what I'm looking for, since this is basically just rerouting the batch request to the regular post, which will still require some extra work on the backend to process, since it may still be delivering changes to multiple entities at once, for example when multiselect is activated and more than one card is moved to a different column. I was rather hoping, the Adaptor would issue multiple standard OData POST requests containing only one entry. But, I think I have understood the methods available to me.

Is there perhaps some more documentation available on the topic? For example, I could not find anything on the "batchRequest" function you are overwriting anywhere in the documentation page you referenced. I have already tried implementing a custom adaptor myself instead of using OData, but I found the documentation to be very sparse on the topic in terms of what you can override, what the signatures are, what is expected to be returned, etc.

Thanks for your help and best regards,
Christoph


AP Arun Palaniyandi Syncfusion Team April 6, 2018 01:40 PM UTC

  
Dear Christoph,     
       
Thanks for your update.    

Query1:”since this is basically just rerouting the batch request to the regular post, which will still require some extra work on the backend to process, since it may still be delivering changes to multiple entities at once, for example when multiselect is activated and more than one card is moved to a different column. I was rather hoping, the Adaptor would issue multiple standard OData POST requests containing only one entry. But, I think I have understood the methods available to me.” 
 
As per the current implementation, our Kanban will do a batch request for every change and this is the current behavior of our Kanban. This is because we have given the saveChanges method to load all the requests as a batch in Odata. Hence as shared in the previous update we can stop this $batch by customizing the batchRequest method using the custom Adaptor only. Also, this will handle multiple cards when multiselect is activated and will take all the card's data in the changed parameter. So this won’t cause any issue in the standard post. 
 
 
Query2 :”Is there perhaps some more documentation available on the topic? For example, I could not find anything on the "batchRequest" function you are overwriting anywhere in the documentation page you referenced. I have already tried implementing a custom adaptor myself instead of using OData, but I found the documentation to be very sparse on the topic in terms of what you can override, what the signatures are, what is expected to be returned, etc. “ 

We have considered your feedback on documentation. We will update this in our future document improvement.  

Please let us know if you have any queries in future. 
 
Arun P. 


Loader.
Up arrow icon