knockout.js - knockout-kendo.js data binding issue -


i using knockout-kendo.js knockout.js binding kendo grid. if bind object's first level property works fine. here sample - http://jsfiddle.net/rniemeyer/jztg5/

in above example items property defined in viewmodel (i.e. viewmodel.items)

however if use object's second level property bind kendo grid, doesn't work. here sample binding doesn't work - http://jsfiddle.net/thakkar/qhf2w/3/

in example, items property not directly defined in viewmodel. instead property of object used in viewmodel. (i.e. viewmodel.obj.items)

var item = function(id, name, type) {     this.id = id;     this.name = ko.observable(name);     this.type = type; };  var vm2 = function() {     this.items = ko.observablearray([         new item(1, "one", "a"),         new item(2, "two", "b"),         new item(3, "three", "a")     ]);  var viewmodel = function() {     this.obj = ko.observable(new vm2()) };  ko.applybindings(new viewmodel()); 

here updated fixed fiddle:

http://jsfiddle.net/diananassar/z439c/2/

basically, missing curly brace [you had console error]. main thing is, if want drill down 2 levels had bind grid this:

kendogrid: {data:obj().items(),scrollable: false,columns: [                             { field: 'id', title: 'id', width: 150 },                             { field: 'name', title: 'name' },                             { field: 'type', title: 'type' }                         ] } " 

not:

kendogrid: {data:obj.items,scrollable: false,columns: [                             { field: 'id', title: 'id', width: 150 },                             { field: 'name', title: 'name' },                             { field: 'type', title: 'type' }                         ] } " 

knockout observables functions, set value passing new value argument function, and read passing no arguments.

i hope helps.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -