javascript - Extending kendo multiselect and working with MVVM -


i'm trying extend kendo multiselect has default data source templates. it's working except pre-loaded values in mvvm object. when start updating exented multiselect, value of mvvm gets updated, initial items not pre-loaded:

kendo.ui.plugin(kendo.ui.multiselect.extend({     init: function(element, options) {         var ds = new kendo.data.datasource({             type: "json",             serverfiltering: true,             transport: {                 read: {                     url: "/securityentities",                     datatype: "json"                 },                 parametermap: function(data) {                     return {                         prefixtext: '',                         count: 5,                         getusers: true,                         getgroups: false                     };                 }             },             schema: {                 data: function(data) {                     console.log($.parsejson(data));                     return $.parsejson(data);                 }             }         });         options = options == null ? {} : options;         options.itemtemplate = "...";         options.tagtemplate = "...";         options.datasource = ds;          kendo.ui.multiselect.fn.init.call(this, element, options);     },     options: {         name: 'entitymultiselect'     } }));  kendo.data.binders.widget.entitymultiselect =  kendo.data.binders.widget.multiselect; 

then html is:

<div data-bind="value: machine.managers" data-role="entitymultiselect"       data-delay="400" data-animation="false"       data-placeholder="select users notify"></div> 

and binding whole container page's viewmodel object.

i've seen other people have issues problem , added

kendo.data.binders.widget.entitymultiselect =      kendo.data.binders.widget.multiselect; 

(and yes seem bug)

but still doesn't work.

when there values in machine.managers, doesn't load them. however, if add values multiselect, added machine.managers .

edit:

i've added live example

at least in demo it's trivial problem: data-value-field wrong. result, binder can't match selected elements.

instead of

<div data-role="entitymultiselect"   data-bind="value: selected"   data-value-field="productid"></div> 

you need

<div data-role="entitymultiselect"   data-bind="value: selected"   data-value-field="productid"></div> 

(working demo)

since you're not defining value field in code in question, might same issue.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -