Grid datasource option vs setDataSource method

4 posts, 0 answers
  1. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 18 Jun 2014 Link to this post

    Hey guys,

    Having an issue and wondering if I am doing something wrong. What I'm trying to achieve is initialize the grid on the page load and set the datasource at some other point (e.g. button click) using the setDataSource method but it won't load. Am I missing something or doing it wrong?

    Working fine - Grid initialize using grid datasource option:
    http://jsfiddle.net/dannycabrera/77Gbn/

    Not working - Grid setDataSource method:
    http://jsfiddle.net/dannycabrera/77Gbn/2/

    Thanks for the help.
  2. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 18 Jun 2014 Link to this post

    *Edit* - working links:

    Working fine - Grid initialize using grid datasource option:
    http://jsfiddle.net/dannycabrera/77Gbn/

    Not working - Grid setDataSource method:
    http://jsfiddle.net/dannycabrera/77Gbn/2/
  3. Kendo UI is VS 2017 Ready
  4. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 20 Jun 2014 Link to this post

    Hi Warren,

    I would recommend passing a DataSource object to the setDataSource method. For example: 
    var ds = new kendo.data.DataSource({
        data: [{"Brand":"Chevrolet","Model":"Corvette","Color":"Red","Doors": 2},
               {"Brand":"Ford","Model":"Mustang","Color":"Blue","Doors": 2}]
    });
     
    $("#grid").data("kendoGrid").setDataSource(ds);


    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Warren
    Warren avatar
    24 posts
    Member since:
    May 2008

    Posted 20 Jun 2014 in reply to Alexander Popov Link to this post

    Thanks Alexander, exactly what I needed. Working great now.
Back to Top
Kendo UI is VS 2017 Ready