2

i have a kendo multiselect which is using a tagTemplate so that when you select options it displays x of y selected. My problem is, when an item is added to the datasource i need to update parameter y but i don't know how to refresh the template. Here's my html template and my js code:

HTML Template:

<script id="SelectedViewsTagTemplate" type="text/x-kendo-template">
    #:values.length# #='@Html.Raw(rm.GetString("STR_OF"))# #:total-1#
</script>

Javascript for tagtemplate:

            tagTemplate: function (dataItem) {
                dataItem.total = _getTotal.call(this);
                dataItem.total += dataItem.AddMode ? 1 : 0;
                return kendo.template($("#SelectedViewsTagTemplate").html())(dataItem);
            }

I've tried triggering the "change" event to get it to update but it doesn't seem to work, aside from recreating the multiselect i don't know how to refresh the template

philr
  • 1,860
  • 1
  • 21
  • 31

1 Answers1

0

In case anyone else runs into this problem I ended up finding a work-around to refreshing the multiSelect template.. recreate the object containing the elements that you use in your template in js, and call the template function like this:

var templateObject = {
   values: currentMultiSelect.value(),
   total: currentMultiSelect.value().length
};
currentMultiSelect.options.tagTemplate(templateObject);

since i only use total and values in my template those are the only properties i need in my object

philr
  • 1,860
  • 1
  • 21
  • 31