HOWTO : creating a custom UrlAdaptor

Hi,

I'm looking for the full docu to be able to create our own urladaptor. I cannot find a nice example nor a list of functions to override.
The adaptor is to be used with a datamanger for the schedule component in an asp.net  core application.

We want to be able to act before a request to the server is sent from the component (read : alter that request) and act upon the response (read: manipulate the data from the response before it is handed over to the schedule component).


rgds

johnny



1 Reply

BS Balasubramanian Sattanathan Syncfusion Team April 21, 2020 11:49 AM UTC

Hi Johnny, 
 
Greetings from Syncfusion Support. 
 
We have validated your requirement “HOWTO : creating a custom UrlAdaptor” at our end and prepared a sample based on that using created event like below code snippets. Kindly refer the below UG to know more details about custom adaptor. 

function onCreated() { 
    class CustomAdaptor extends ej.data.ODataV4Adaptor { 
        processResponse() { 
            var i = 0; 
            // calling base class processResponse function 
            var original = super.processResponse.apply(this, arguments); 
            // adding employee id 
            original.forEach(function (item) { 
                item['EmpID'] = ++i 
            }); 
            return original; 
        } 
    } 
    var dataManager = new ej.data.DataManager({ 
        url: 'https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData', 
        adaptor: new CustomAdaptor 
    }); 
    var dataQuery = new ej.data.Query().from("Events"); 
    var schObj = document.querySelector('.e-schedule').ej2_instances[0]; 
    schObj.eventSettings.dataSource = dataManager; 
    schObj.eventSettings.query = dataQuery; 
} 

 
Note: Currently, the UG enhancement is in progress for the above UG topic and it will be refreshed in online our next weekly patch release which is expected to roll out by next week. We would appreciate your valuable patience until then. You can track the status through the below feedback link. 

 
Regards, 
Balasubramanian S 


Loader.
Up arrow icon