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

DataSource Read function with parameters

1 Answer 570 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 2
Iron
Iron
Pierre asked on 27 Aug 2013, 08:39 PM
Hi, I currently try to tweak the dataSource Read function to load local data instead of using URL.
In my page I got several grid binding to several dataSource (I do not know at loading time because all page is dynamically created). All dataSource take data in one Read function that read an hugde local data array. I need to know witch DataSource (or Grid) call the Read function. But I can't found a way to do this.
Thanks for your help
function CreeDataSourceGroupes() {
    var that = this;
 
    //Pour cahque groupe prĂ©sent
    $("[id*='Groupe'][data-role='grid']").each(function () {
 
        var groupeID = $(this).attr('Id')
        dsGroupes = new kendo.data.DataSource(
                   {
                       groupId: 'ID1',         // ============= NEED TO READ THIS ID SET WHEN CREATING THE DS
                       transport: {
                           read: function (options) {
                               that.DsGroupeRead(options);
                           }
                       }
                   });
 
     
            $(this).data('kendoGrid').setDataSource(dsGroupes);
    })
}
 
function DsGroupeRead (options, x)
{
 
    // NEED THE GROUP ID HERE
 
    //var data = speakerData1
    //options.success(data);
}

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 29 Aug 2013, 07:16 AM
Hi Pierre,

Although, it is not possible to read the DataSource configuration from the transport, in your scenario you could capture and pass the parameter directly into the DsGroupeRead function:

var groupeID = $(this).attr('Id')
dsGroupes = new kendo.data.DataSource(
   {                    
       transport: {
           read: function (options) {
               that.DsGroupeRead(options, groupeID);
           }
       }
   });

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Pierre
Top achievements
Rank 2
Iron
Iron
Answers by
Rosen
Telerik team
Share this question
or