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

DataSource property update and refresh?

3 Answers 1912 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 09 Mar 2015, 10:31 PM
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!

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 11 Mar 2015, 12:14 PM

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!
 
0
John
Top achievements
Rank 1
answered on 12 Mar 2015, 02:19 PM
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
0
Alex Gyoshev
Telerik team
answered on 16 Mar 2015, 08:50 AM

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!
 
Tags
TreeList
Asked by
John
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
John
Top achievements
Rank 1
Share this question
or