首页 > 解决方案 > 在 ExtJS 6 中创建插件

问题描述

ExtJS 3版本中,我创建了一个plugin来显示颜色,combobox但我无法pluginExtJS 6.

它给出了错误:

combo.onRender.createSequence 不是函数

这是代码,它适用于ExtJS 3

Ext.namespace('Ext.ux.plugins');

Ext.ux.plugins.ColorCombo = function (config) {
    Ext.apply(this, config);
};

Ext.extend(Ext.ux.plugins.ColorCombo, Ext.util.Observable, {
    init: function (combo) {
            Ext.apply(combo, {
                tpl: '<tpl for="."><div class="search-item">' + 'Color Name: {' + combo.titleField + '}, Hex Value: {' + combo.displayField + '} <div style="float:right;width:50px;height=10px;background-color:{' + combo.displayField + '};">&nbsp;</div>' + '</div></tpl>',

                onRender: combo.onRender.createSequence(function (ct, position) {
                    // adjust styles
                    this.wrap.applyStyles({
                        position: 'relative'
                    });
                    this.el.addClass('ux-color-combo-input');

                    // add div for color
                    this.color = Ext.DomHelper.append(this.el.up('div.x-form-field-wrap'), {
                        tag: 'div',
                        style: 'position:absolute',
                        id: 'ColorHexBlock'
                    });
                }), // end of function onRender

                setColorCls: function () {
                    var rec = this.store.query(this.valueField, this.getValue()).itemAt(0);
                    if (rec) {
                        this.color.className = 'ux-color-combo-color ';
                        this.color.innerHTML = '<div style="float:right;width:50px;height=10px;background-color:' + rec.get(this.displayField) + ';">&nbsp;</div>';
                    }
                }, // end of function setColorCls

                setValue: combo.setValue.createSequence(function (value) {
                    this.setColorCls();
                });
            });
        } // end of function init
}); // end of extend

我该怎么做ExtJS 6 classic

标签: javascriptextjssencha-touchextjs6extjs6-classic

解决方案


推荐阅读