Search code examples
javascriptdevextreme

Devextreme scheduler bind function to dataSource?


I have an function which does ajax call and gets data. The function is similliar to

function loadData(callback) {
    //do ajax
    if(callback) {
       callback(data.data);
    }
}

How can i bind this function to the scheduler dataSource? Tried with this

options: {
   dataSource: loadData(function(data) {
        return data;
   });
}

and it does return the data i need when i do console.log in the function but if i want to add another options like views it expects ; somewhere and it doesnt work

How can i achieve that and render the scheduler with the data?


Solution

  • In order to bind a remote data to dxScheduler I suggest you use the customStore object.

    var dataSource = new DevExpress.data.DataSource({
        load: function() {
            // make ajax request here and return promise
        }
    });
    
    $("#scheduler").dxScheduler({
        //...
        dataSource: dataSource 
    });
    

    The demo is here.

    More information about DevExtreme data layer is here.