How to set datasource URL property to relative URL?

2 posts, 1 answers
  1. Laksh
    Laksh avatar
    25 posts
    Member since:
    Mar 2011

    Posted 10 Apr 2015 Link to this post

    I have MVC application which has Kendo grid. The datasource's URL property is set to /Users/GetRequests . The application runs fine locally in visual studio. In production the application is hosted under virtual directory www.mycompany.com/dashboard 

    So when we deploy application to production its not working with the url /Users/GetRequests, however if i change the url to /Dashboard/Users/GetRequests then it works but then it will not work locally. 

    How can i set the relative URL to datasource?

    $(document).ready(function () {
        $.ajaxSetup({ cache: false });
     
        $("#dashboardTabs").kendoTabStrip();
     
        $("#downloadGrid").kendoGrid(
            {
                dataSource: new kendo.data.DataSource({
                    transport:{
                        read: {
                            url: "/Users/GetRequests",
                            dataType: "json"
                        }
                    },
                    pageSize: 10
                }),
     
                pageable: {
                    refresh: true,
                    pageSizes: [5,10,15,20]
                },
     
                columns:
                [
                    { title: "Request Type", field: "RequestType", width: 85 },
                    { title: "Requested On", field: "RequestedOn", width: 75 }
                ]
            });
    });

  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 14 Apr 2015 Link to this post

    Hello Laksh,

    The dataSource.transport.url option accept a function, that you can use to dynamically return different url whenever read is executed. Please check the following documentation article that I believe will help:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.url

    Regards,
    Kiril Nikolov
    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
Back to Top