长篇文章的Aplogies。这是问题的延续: Extjs adding multiple items to a window does not work 在这个问题中,我有一个这样定义的网格:
var updater = msgDetailsPanel.getUpdater();/*Added new*/
var detailGrid = new Ext.grid.GridPanel({
id:'detailGrid',
store: dataStore,
collapsible: false,
columnLines: false,
enableHdMenu: false,
header: false,
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
{id:'msgId',hidden: true, dataIndex: 'msgId'},
{sortable: true, dataIndex: 'deliveryAddr'},
{sortable: true, dataIndex: 'deliveryDate'},
{sortable: true, dataIndex: 'status', renderer:function(value, p, record){
return String.format( '<font color="009966">{0}</font>', value );}},
{header: 'info',xtype: 'templatecolumn',tpl: '<a href="#" onClick = "alert({msgId})">View Message Details</a>'}
]
}),
viewConfig: {
forceFit:true
},
columnLines: false,
frame:false,
collapsible: false,
animCollapse: false,
title: alertName,
disableSelection: true,
deferRowRender:false
});
我希望将onClick = "alert({msgId})"
替换为onClick = "updater.update({msgId})"
因此,点击超级链接“查看邮件详细信息”,Panel将填充msgId。
但我明白了:
javascript error: this.ds.fields.get(...).name is null or not an object.
我怎样才能做到这一点?
答案 0 :(得分:0)
由于你的ID('msgId')是硬编码的,我建议一个简单的方法:
Ext.onReady( function()
{
// When the DOM is ready, establish a handler (onClick) for the msgId node.
// Again, msgId is hardcoded - not certain why you would pass it as a parameter to updater -
// but createDelegate passes msgId as a parameter.
Ext.get('msgId').on( 'click', updater.update.createDelegate( this, [{msgId}], 0 ))
});