扩展Kendo MultiSelect [英] Extend Kendo MultiSelect

查看:111
本文介绍了扩展Kendo MultiSelect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过扩展现有剑道多选小部件来创建它.目的是在输入下方的div中显示标签列表.

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.

我在此代码中的目标是在小部件的select事件上在单独的div中呈现标签列表,然后返回基本小部件的select事件(Kendo MultiSelect),但返回基本小部件的select事件返回dataItem undefind错误.我在做什么错了?

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); 

推荐答案

我已经测试了代码,刚开始却出现错误-未定义".在添加var that = this之后;在"_select"方法中,我注意到您必须将"that"作为第一个参数添加到调用函数.这是在我这边正常工作的代码- https://dojo.telerik.com/@zdravkov /ApOVApiV

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

这篇关于扩展Kendo MultiSelect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆