Is there a way to reset the URL of a datasource

4 posts, 1 answers
  1. Alvaro
    Alvaro avatar
    6 posts
    Member since:
    Dec 2011

    Posted 16 Jan 2012 Link to this post

    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
  2. Answer
    John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2012 Link to this post

    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
  3. Kendo UI is VS 2017 Ready
  4. Alvaro
    Alvaro avatar
    6 posts
    Member since:
    Dec 2011

    Posted 17 Jan 2012 Link to this post

    Thanks

    That worked fine!
  5. John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 17 Jan 2012 Link to this post

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