Extend Kendo MultiSelect
Asked Answered
B

1

0

I'm trying to create a new kendo multi-select widget by extending the existing one. The goal is to show the tag list in a div below the input.

My goal here in this code is to render the tag list in a separate div on the select event of the widget, and then return the select event of the base widget (Kendo MultiSelect), but the select event of the base widget returns a dataItem undefind error. What am I doing wrong?

(function ($) {
    var customMultiSelect = kendo.ui.MultiSelect.extend({
        init: function (element, options) {
            var that = this;
            kendo.ui.MultiSelect.fn.init.call(that, element, options);

            // Hide the tag list...
            var id = that.element.attr('id');
            that.wrapper.find(`ul#${id}_taglist`).addClass("hidden");

            that.element.on("select", that._select);
        },
        options: {
            name: "CustomMultiSelect"
        },
        _select: function (e) {
            // code to render the tag list in a div goes here

            that.trigger("select", e);
            return kendo.ui.MultiSelect.prototype._select.call(e);
        }   
    });

    kendo.ui.plugin(customMultiSelect);
})(jQuery, document); 
Betweentimes answered 27/9, 2018 at 21:25 Comment(0)
R
2

I have tested the code and at first got and error - 'that is not defined'. After adding var that = this; in the '_select' method I noticed that you have to add 'that' as a first parameter to the call function. Here is the code that worked correctly at my side - https://dojo.telerik.com/@zdravkov/ApOVApiV

Rothenberg answered 28/9, 2018 at 13:6 Comment(1)
Awesome! Thanks!Betweentimes

© 2022 - 2024 — McMap. All rights reserved.