这是我在网格中使用组合框的代码:
{
header: 'FSCS',
dataIndex: 'acntOvrrideTypeCd',
flex: 1,
renderer: function(val, metaData, record, rowIndex, colIndex) {
var id = Ext.id();
var store = new Ext.data.Store({
fields: ['code', 'description'],
data: [{
"code": "",
"description": ""
}, {
"code": "E",
"description": "E"
}, {
"code": "D",
"description": "D"
}, {
"code": "S",
"description": "S"
}]
});
Ext.Function.defer(
(function() {
var cb = Ext.create('Ext.form.ComboBox', {
id: 'acntOvrrideTypeCd-' + rowIndex,
queryMode: 'local',
renderTo: id,
store: store,
forceSelection: true,
triggerAction: 'all',
lazyRender: true,
size: 5,
valueField: 'code',
displayField: 'description',
value: val
//listeners:{
// scope: this,
// 'select': Ext.getCmp('amlFscsForm').controller.amlShow(rowIndex)
//}
});
cb.on(afterrender, function() {
console.log("------- box---" + rowIndex);
Ext.getCmp('amlFscsForm').controller.amlShow(rowIndex);
});
}), 0.25);
console.log("i----------" + id);
return (Ext.String.format('<div id="{0}"></div>', id));
}
}
未激发“‘afterrender”事件。我需要在组件渲染后启用或禁用组件。
有人能帮上忙吗?
发布于 2012-08-22 12:34:47
这只是一个拼写错误,afterrender应该用引号括起来,否则你只会为未定义的事件添加函数。
cb.on('afterrender',function(){
console.log("------- box---" + rowIndex);
Ext.getCmp('amlFscsForm').controller.amlShow(rowIndex);
});
发布于 2012-08-22 12:55:10
你的代码有一些问题。
Ext.grid.plugin.CellEditing
插件,它将按需创建一个字段,而不是在列呈现时创建。此外,每次刷新网格视图时,都会为网格中的每一行创建另一个存储区和组合框。对性能不好,对用户体验也不好。Ext.defer(function(){ // do stuff },25);
on
方法时,您需要将事件指定为字符串。如果您使用listeners配置(您已将其注释掉),则只需执行以下操作:监听器:{ Ext.getCmp('amlFscsForm').controller.amlShow(rowIndex);:function(){ box(“-console.log-”+ rowIndex);select: function(){ Ext.getCmp('amlFscsForm').controller.amlShow(rowIndex);} }
需要注意的是,这些侦听器函数的作用域默认为组件本身(您的组合框),因此scope: this
是不必要的。除非您希望作用域是创建此组合框的任何对象,即。
第一点是最重要的。考虑使用CellEditing (或RowEditing)插件,我保证事情会顺利得多。
https://stackoverflow.com/questions/12072119
复制相似问题