DataSource property update and refresh?

4 posts, 0 answers
  1. John
    John avatar
    5 posts
    Member since:
    Feb 2015

    Posted 09 Mar 2015 Link to this post

    I am trying to do something very simple in concept but am having no luck whatsoever in getting it to work.  All I would like to do is update a treelist datasource via an ajax call that passes a different parameter each time the user selects a new user id from a dropdown list.

    Changing the dropdown list choice simple calls the data source again with the new parameter.  I am finding that my attempts to modify the transport options via javascript won't be resubmitted.  That is I can see via the debugger that I have changed transport options read/url but I can get the datasource to refresh by using setDataSource() or fetch().  I don't know if there is a correct sequence of options to change but this is quite frustrating.

    The treelist is essentially a hierarchical list of records specific to the user selected in a drop down list.  All I want to do is change that user and remotely databind again to refresh the grid.  Why is this so difficult?

    Thanks!
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 11 Mar 2015 Link to this post

    Hello John,

    You can pass parameters to the dataSource read method:

        var treelist = $("#treelist").data("kendoTreeList");
        treelist.dataSource.read({ param: "value" });

    Alternatively, you can add parameters when the read request is initiated by defining the dataSource transport.read.data configuration option as a function (see example in docs).

    Regards,
    Alex Gyoshev
    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
  4. John
    John avatar
    5 posts
    Member since:
    Feb 2015

    Posted 12 Mar 2015 in reply to Alex Gyoshev Link to this post

    Thanks Alex,

    From your reply it looks as though I don't need to create a new instance of a datasource object.  I can just update the url parameter of the read function of the existing datasource previously loaded.  I did review the API and my issue was that no combination of calls seemed to trigger a call back to my controller action.

    Do I need to issue a fetch() after modifying the URL parameter?
    Thank you
  5. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 16 Mar 2015 Link to this post

    Hello John,

    If you want to reload the TreeList data, you need to call the DataSource read method, or change the DataSource instance via the TreeList setDataSource method. See this Dojo snippet for a demo. If this is not what you are after, please modify the snippet so that it shows the problem.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready