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

how to make the url: a function?

3 Answers 106 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 22 Dec 2011, 07:21 PM
I need to alter the url for my service based upon user input so am using a function something like this :-

url: function() {
     return '/myservice/search/' + $("#txtSearch").val();
},

this does not seem to work .. the url gets mangled.

however if I use the same idea for the data: to pass extra parameters it works fine

How can I make the url a function so I can change the value?

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Dec 2011, 09:47 AM
Hi,

 The url setting is passed without any modification to jQuery.ajax which in turn performs the ajax request. It seems that the latter does not support functions though. The only solution I can suggest is to use the data setting to provide query string arguments to the url.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Joel
Top achievements
Rank 1
answered on 11 Jan 2012, 05:49 AM
-delete-
0
John
Top achievements
Rank 1
answered on 11 Jan 2012, 10:02 PM
I have found a solution that works for me.  I needed to be able to change the URL for a datasource so this works :-
$("#txtSearch").keydown(function(e) {
    if (e.keyCode === kendo.keys.ENTER) {
        // update url
        searchDataSource.options.transport.read.url ="/myservice/search/" + $("#txtSearch").val();
        searchDataSource.read();
    }
});

Tags
Data Source
Asked by
John
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Joel
Top achievements
Rank 1
John
Top achievements
Rank 1
Share this question
or