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

How to set datasource URL property to relative URL?

1 Answer 1918 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Laksh
Top achievements
Rank 1
Laksh asked on 10 Apr 2015, 08:24 PM

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 }
            ]
        });
});

1 Answer, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 14 Apr 2015, 08:38 AM

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!
 
Tags
Data Source
Asked by
Laksh
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or