【发布时间】:2013-05-08 20:25:48
【问题描述】:
我正在使用 ArrayStore 并通过添加模型记录来填充它。 此存储与数据网格相关联。
现在 arraystore 对象被完美地填充,但数据没有出现在网格中。其实在调试的时候发现grid的store(datagrid.store)也有数据,但是还是没有显示在屏幕上!!
以下是我的代码。
型号:
Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLAttributeValueModel', {
extend: 'Ext.data.Model',
fields: [
{
name: 'attribute',
type: 'string'
},
{ name: 'attributeValue',
type: 'string'
}
]
});
商店:
var attrValueStore = Ext.create('Ext.data.ArrayStore', {
autoSync: true,
model: 'Ext.ux.window.visualsqlquerybuilder.SQLAttributeValueModel'
});
网格
Ext.define('Ext.ux.window.visualsqlquerybuilder.SQLAttributeValueGrid', {
//requires: ['Ext.ux.CheckColumn'],
autoRender: true,
extend: 'Ext.grid.Panel',
alias: ['widget.attributevaluegrid'],
id: 'SQLAttributeValueGrid',
store: attrValueStore,
columnLines: true,
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})],
columns: [
{ /*Expression */
xtype: 'gridcolumn',
text: 'Attribute',
sortable: false,
menuDisabled: true,
flex: 0.225,
dataIndex: 'attribute'
},
{ /*Attribute Values*/
xtype: 'gridcolumn',
editor: 'textfield',
text: 'Values',
flex: 0.225,
dataIndex: 'attributeValue'
}
],
initComponent: function () {
this.callParent(arguments);
}
});
显示网格的模式窗口
var attributeValueForm = Ext.create('Ext.window.Window', {
title:'Missing Attribute Values',
id: 'attributeValueForm',
height:500,
width:400,
modal:true,
renderTo: Ext.getBody(),
closeAction: 'hide',
items:[
{
xtype: 'attributevaluegrid',
border: false,
//height: 80,
region: 'center',
split: true
}
],
buttons: [
{
id: 'OKBtn',
itemId: 'OKBtn',
text: 'OK',
handler: function () {
Ext.getCmp('attributeValueForm').close();
}
},
{
text: 'Cancel',
handler: function () {
Ext.getCmp('attributeValueForm').close();
}
}
]
});
现在在显示模态窗口时,我检查了存储对象的值以及网格对象内部的存储。两者都有正确的数据。
但是当窗口打开时,我得到一个空白网格
【问题讨论】:
-
您永远不会在任何地方加载商店。你不给它分配代理或给它内联数据。商店是空的。
-
@EvanTrimboli:我理解你的意思,但实际上我错过了添加将数据添加到商店的代码。我在另一种方法中单独执行此操作,其中我创建一个模型对象,为其属性设置值并将其添加到存储中。所以商店有数据。
标签: extjs extjs4 extjs-stores