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

Observable array passing local variable to datasource

1 Answer 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 28 Feb 2014, 05:41 PM
I am passing a value from a param from a click event, which works fine;

 <a data-bind="events: { click: roomselect }"  data-target="detailPane">#: desc# </a>

 but I want to get this value to another method within the view-model. I was trying to use "set " but it does not assign the value.  

(I am trying to get the value to the line  in the method init below: url: "http://myURL/api/room/" +  this.roomSelected + "/children",)


 RoomsViewModel = kendo.data.ObservableObject.extend({
        roomsDS: null,
        roomDS:null,
        roomSelected: null,
        
        roomselect: function(e) {
            var that = this;
            that.set("roomSelected", e.data.id);
        },     

        init: function () {
            var that = this, roomDataSource;
            kendo.data.ObservableObject.fn.init.apply(that, []);                 
            roomDataSource = new kendo.data.DataSource({
            
            transport: {
                read: {
                    url: "http://myURL/api/room/" +  this.roomSelected + "/children",
                    dataType: "json",
                    type: "GET"
                },
.......

1 Answer, 1 is accepted

Sort by
0
Accepted
Petyo
Telerik team
answered on 03 Mar 2014, 10:04 AM
Hi Alex,

you can achieve this by assigning a function to the datasource url configuration option; it will be re-evaluated with each request. 

                    url: function() {
return "http://myURL/api/room/" +  that.roomSelected + "/children";
}


Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Alex
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or