ExtJS网格组合呈现程序不工作
我在ExtJS 4.2.1应用程序中有一个网格,它有一个带有组合编辑器的可编辑列 我需要使用组合的ExtJS网格组合呈现程序不工作,extjs,extjs4,extjs4.1,extjs4.2,extjs-mvc,Extjs,Extjs4,Extjs4.1,Extjs4.2,Extjs Mvc,我在ExtJS 4.2.1应用程序中有一个网格,它有一个带有组合编辑器的可编辑列 我需要使用组合的DisplayField中的值呈现列,但是comboStore.getCount()=0 这是我的表格: Ext.define('App.employee.Grid', { extend: 'Ext.grid.Panel', requires: ['Ext.grid.plugin.CellEditing'], alias: 'widget.employee.grid',
DisplayField
中的值呈现列,但是comboStore.getCount()=0
这是我的表格:
Ext.define('App.employee.Grid', {
extend: 'Ext.grid.Panel',
requires: ['Ext.grid.plugin.CellEditing'],
alias: 'widget.employee.grid',
config: {
LocationId: 0
},
initComponent: function() {
var me = this,
store = me.buildStore(),
comboStore = Ext.create('App.store.catalog.Location', { autoLoad: true });
me.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false,
listeners: {
edit: function(editor, e) {
}
}
});
me.cellEditing = new Ext.grid.plugin.CellEditing({
clicksToEdit: 1
});
Ext.applyIf(me, {
plugins: [me.rowEditing],
columns: [{
xtype: 'rownumberer',
text: '#',
width: 50,
sortable: false,
align: 'center'
//locked: true
},{
text: 'Number',
dataIndex: 'EmployeeNumber',
align: 'center',
width: 90
}, {
text: 'Name',
dataIndex: 'EmployeeName',
flex: 1
}, {
text: 'Location',
dataIndex: 'LocationId',
width: 140,
renderer: function(value) {
// HERE!!!
// me.comboStore.getCount() = 0 so I never get a record
var record = me.comboStore.findRecord('LocationId', value);
return record.get('Description');
},
editor: {
xtype: 'combobox',
typeAhead: true,
triggerAction: 'all',
store: comboStore,
displayField: 'Description',
valueField: 'LocationId',
queryMode: 'local',
listConfig: {
width: 250,
// Custom rendering template for each item
getInnerTpl: function() {
return '<b>{Code}</b><br/>(<span style="font-size:0.8em;">{Description}</span>)';
}
}
}
}],
store: store,
});
me.callParent(arguments);
}
});
Ext.define('App.employee.Grid'{
扩展:“Ext.grid.Panel”,
需要:['Ext.grid.plugin.CellEditing'],
别名:“widget.employee.grid”,
配置:{
位置ID:0
},
initComponent:function(){
var me=这个,
store=me.buildStore(),
comboStore=Ext.create('App.store.catalog.Location',{autoLoad:true});
me.rowEditing=Ext.create('Ext.grid.plugin.rowEditing'{
单击移动编辑器:1,
自动取消:错误,
听众:{
编辑:函数(编辑器,e){
}
}
});
me.celleediting=新建Ext.grid.plugin.celleediting({
单击编辑:1
});
Ext.applyIf(我{
插件:[me.rowEditing],
栏目:[{
xtype:'行编号者',
正文:“#”,
宽度:50,
可排序:false,
对齐:“居中”
//锁定:对
},{
文本:“编号”,
数据索引:“EmployeeNumber”,
对齐:'居中',
宽度:90
}, {
文本:“名称”,
数据索引:“EmployeeName”,
弹性:1
}, {
文本:“位置”,
dataIndex:'LocationId',
宽度:140,
渲染器:函数(值){
//这里!!!
//me.comboStore.getCount()=0,因此我从未获得记录
var record=me.comboStore.findRecord('LocationId',value);
返回记录.get('Description');
},
编辑:{
xtype:“组合框”,
是的,
触发动作:“全部”,
商店:comboStore,
displayField:'说明',
valueField:'LocationId',
queryMode:'本地',
列表配置:{
宽度:250,
//每个项目的自定义渲染模板
getInnerTpl:函数(){
返回“{Code}
({Description})”;
}
}
}
}],
店:店,,
});
me.callParent(参数);
}
});
问题出在呈现程序
函数中,因为组合存储
总是空的。奇怪的是,在我的视图中,如果我单击编辑行并打开组合,组合中就有值
[更新]
我认为我的comboStore在加载时会有延迟,因此在comboStore加载之前会触发渲染器。我明白了这一点,因为如果我在chrome中调试并等待几秒钟,它就会工作。。。但不知道如何强制等待comboStore加载
关于如何解决这个问题有什么线索吗?感谢您的帮助。以下是一些解决方案: