【发布时间】:2011-06-17 19:56:11
【问题描述】:
在 EditorGridPanel 中选择单元格时出现错误。这是我的代码的 sn-p:
var bannerGrid = new Ext.grid.EditorGridPanel({
store: bannerStore,
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true,
menuDisabled: true
},
columns:
{
header: '<img src="img/oo-icon.png" /> <img src="img/network-icon.png" />',
width: 52,
dataIndex: 'inventory',
align: 'center',
renderer: inventoryIcon,
}, {
header: "Name",
dataIndex: 'bannerName',
editor: new Ext.form.TextField({ allowBlank: false }),
width: 300
}, {
header: "Advertiser",
dataIndex: 'advertiser',
editor: advertisersDropdownGrid,
}, {
header: "Art Type",
dataIndex: 'artType',
editor: artTypeDropdownGrid,
}, {
......
每个“编辑器”都是在网格之前定义的下拉菜单。奇怪的是,包含 TextField 的编辑器不会抛出同样的错误。
我在选择单元格时遇到的错误是:
c.getItemCt() is undefined
[Break On This Error] c.getItemCt().removeClass('x-hide-' + c.hideMode);
同样,这只发生在 ComboBox 编辑器上!
通过进一步检查,错误来自 ext 本身的这一部分:
onFieldShow: function(c){
c.getItemCt().removeClass('x-hide-' + c.hideMode);
if (c.isComposite) {
c.doLayout();
}
},
这似乎是 FormLayout 部分的一部分。
有什么想法吗?我已经尝试定义 Combo 的内联,但没有解决它。
谢谢!
编辑:以下是我使用类定义 Combo 的方式。
我定义了我的 ComboBoxJSON 类:(出于隐私考虑,我已将命名空间设为空白)
***.***.***.ComboBoxJSON = Ext.extend(Ext.form.ComboBox, {
url: '',
root: '',
valueField: 'id',
displayField: 'name',
width: 200,
id: '',
fields: [
{ name: 'id', type: 'int'},
{ name: 'name', type: 'string' }
],
initComponent: function () {
var comboStore = new Ext.data.JsonStore({
id: 'JsonStore',
idProperty: 'id',
autoLoad: true,
idProperty: 'id',
root: this.root,
fields: this.fields,
proxy: new Ext.data.ScriptTagProxy({
api: {
read: this.url,
}
})
});
var config = {
store: comboStore,
displayField: this.displayField,
valueField: this.valueField,
mode: 'local',
minChars: 1,
triggerAction: 'all',
typeAhead: true,
lazyRender: true,
value: this.value,
width: this.width,
id: this.id
}
Ext.apply(this, config);
***.***.***.ComboBoxJSON.superclass.initComponent(this);
}
});
Ext.reg("ibwComboJson", ***.***.***.ComboBoxJSON);
然后我在网格上的 init 之前定义我的组合,如下所示:(我已经屏蔽了 URL,但它确实返回了有效的 JSON)
var advertisersDropdownGrid = new ***.***.***.ComboBoxJSON({
url: '***',
root: 'advertiserList',
id: 'advertisersDropdownGrid'
});
【问题讨论】:
-
你能告诉我们
advertisersDropdownGrid吗? -
我刚刚注意到您在列模型中的列属性错误,您的列对象应该在分配给
columns属性的数组中,这只是复制和粘贴错误吗?跨度> -
@Jaitsu:是的,只是复制粘贴错误让我试着为你们准备一个工作示例。
-
你能告诉我们你的组合框代码吗?