3

I would like to know, why non primitive values are not working in Kendo-Knockout bindings.

I have 2 DropDownLists:

<!-- This one works fine -->
<input data-bind="kendoDropDownList: {
data: Names,
value: SelectectedValue1,
dataTextField: 'Name',
dataValueField: 'ID',
valuePrimitive: true
}" />


<!-- This one doesn't work -->
<input data-bind="kendoDropDownList: {
data: Names,
value: SelectectedValue2,
dataTextField: 'Name',
dataValueField: 'ID',
valuePrimitive: false
}" />

And simple VM:

var datajs = 
    [{'ID':1,'Name':'Name 1'},
     {'ID':2,'Name':'Name 2'},
     {'ID':3,'Name':'Name 3'},
     {'ID':4,'Name':'Name 4'},
     {'ID':5,'Name':'Name 5'}
    ];

var ViewModel = function() 
{
    this.Names = ko.observableArray(datajs);
    this.SelectectedValue1= ko.observable(null);
    this.SelectectedValue2= ko.observable(null);
};

ko.applyBindings(new ViewModel());

First dropdown is using primitive as value, second should bind whole object. But it doesn't work. Both selected values are primitives with ID. Why?

Fiddle: http://jsfiddle.net/RaptorCZ/4x710zbn/

Only way I found is to create computed to get object from collection based on selected ID.

Raptor
  • 392
  • 1
  • 4
  • 21

0 Answers0