initialization - preload the selected values of a kendo multiselect that using a server bound data source and templated tags -


i have kendo multiselect follows.

$("#tags").kendomultiselect({     change: onchange,     datasource: {         transport: {             prefix: "",             read: {                 url: "/opsmanager/api/activity/searchresourcestagged",                 data: getsubmitdata             }         },         serverfiltering: true,         filter: [],         schema: { errors: "errors" }     },     itemtemplate: $('#resourceitemtemplate').html(),     tagtemplate: $('#resourcetagtemplate').html(),     datavaluefield: "k",     value: [{"k":"[109]","n":"all open alerts","icon":"!","all":105}] }); 

with following templates:

<script id="resourceitemtemplate" type="text/x-kendo-template">     <span data-icon="#:data.icon#" class="#: data.s || '' #">&nbsp;#:data.n #</span>       # if (data.d) { #         <div class="details">#: data.d #</div>     # } #     # if (data.details) { #     <div class="details k-state-disabled">         # (var v in data.details) {              var t = typeof data.details[v];             if (t != "object" && t != "function" && v != "uid") { #         <div class="k-button">#: v #: #: data.details[v] #</div>         # } } #     </div>     # } #       </script>  <script id="resourcetagtemplate" type="text/x-kendo-template">     <span data-icon="#:data.icon#" class="tag-content #: data.s || '' #">&nbsp;#:data.n #</span>  </script> <select id="tags" multiple="multiple" name="tags"></select> 

i'm trying preload specific selection , can't seem work.

selection:

[{"k":"[109]","n":"all open alerts","icon":"!","all":105}] 

i've put initialized value in place according documentation , looking multiselect object inside browser see passed in object inside _initialvalues don't see inside _dataitems or in tag list on ui.

any clues how working?

thanks @onabai,

the problem difference in expected content of datasources. datasource loaded not looking "[109]" rather "some string query" , provides specific list around search. need initialize fake datasource control , switch out data source dynamic one.

$("#tags").kendomultiselect({     change: onchange,     datasource: {         transport : {             read: function (op) {                 op.success([{"k":"[109]","n":"all open alerts","icon":"!","all":105}]);             }         }     },     itemtemplate: $('#resourceitemtemplate').html(),     tagtemplate: $('#resourcetagtemplate').html(),     datavaluefield: "k",     value: ["[109]"] }); $("#tags").data("kendomultiselect").setdatasource({     transport: {         read: {             url: "opsmanager/api/activity/searchresourcestagged",             data: getsubmitdata             }         },     serverfiltering: true,     filter: [],     schema: { errors: "errors" } }); 

after works expected.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -