DataSource Read function with parameters

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    212 posts
    Member since:
    Apr 2007

    Posted 27 Aug 2013 Link to this post

    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);
    }
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 29 Aug 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top