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

Is there a way to reset the URL of a datasource

3 Answers 152 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Alvaro
Top achievements
Rank 1
Alvaro asked on 17 Jan 2012, 05:14 AM
Hi

I'm using a datasource to populate a grid. When the page loads for the first time I set the URL variable to the datasource. How can I change the URL of the datasource after it was created? The url changes when the user clicks on several items in the page and I don't want to use data property to send parameters to the url (the url changes and the parameters also).

If I initialize the datasource in every click I have strange behaviour. I've read in the forum that it's not advisable to do that

Thanks for your attention

3 Answers, 1 is accepted

Sort by
0
Accepted
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 02:32 PM
Hi Alvaro,

The transport settings are stored in the dataSource at: dataSource.transport.options.  If you had a dataSource defined as:

ds = new kendo.data.DataSource({
    type: 'json',
    transport: {
        read: '/Home/GetInitialRecords'
    }
});

You could change the dataSource url and requery with the following:

ds.transport.options.read.url = '/Home/GetNewRecords';
ds.read();

This will also update the grid.

Let me know if you would like for me to post a sample application in either ASP.NET MVC ASPX / Razor or Python Django.

Regards,

John DeVight
0
Alvaro
Top achievements
Rank 1
answered on 17 Jan 2012, 04:12 PM
Thanks

That worked fine!
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 04:15 PM
Awesome!

If you get a chance, could you mark my response as the right answer?  It helps other forum users to know what to look for =)  Thanks.

Let me know if there is anything else I can help you with.

Regards,

John DeVight
Tags
Data Source
Asked by
Alvaro
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Alvaro
Top achievements
Rank 1
Share this question
or