javascript - 在 ExtJS 6 中创建插件
问题描述
在ExtJS 3
版本中,我创建了一个plugin
来显示颜色,combobox
但我无法plugin
在ExtJS 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 + '};"> </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) + ';"> </div>';
}
}, // end of function setColorCls
setValue: combo.setValue.createSequence(function (value) {
this.setColorCls();
});
});
} // end of function init
}); // end of extend
我该怎么做ExtJS 6 classic
?
解决方案
推荐阅读
- c# - 从 .net 核心集成测试项目加载引用的程序集不包括来自测试 API 的引用项目
- java - NativeScriptAngular http请求错误Android 4.2
- javascript - 如何从 Ajax 调用中正确编码的 Java 对象获取阿拉伯语值?
- python - 如何判断具有空字符串值的 python 字符串变量在初始化时是使用单引号还是双引号?
- c++ - Qt5:在 QOAuth2AuthorizationCodeFlow 请求中发送标头
- javascript - 最佳实践问题:从电子表格到文档的 Google 应用脚本
- mysql - 如何计算字段的平均值并排除 0 值
- python - Python:多线程上的 CPU 密集型任务
- php - 公共路径在生产中不起作用,但在本地起作用
- c++ - 我们如何计算最多一个跳过的最长公共子串?