2011-08-31 44 views
0

长文章的限制。这是问题的一个延续: Extjs adding multiple items to a window does not work 在的问题,我有过这样定义的网格:更新extjs中的托管iframe面板

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})"更换这样的超链接“查看邮件详细信息”的点击,该小组将填充msgId。 但我得到:

javascript error: this.ds.fields.get(...).name is null or not an object. 

我该如何做到这一点?

回答

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)) 
}); 
+0

嗨,你好,你的意思是......“msgid是硬编码”?谢谢 – Victor

+0

我喜欢使用Ext.id创建所有DOM ID。实质上,它意味着不关心DOM ID的确切价值 - 例如Ext.id(null,'something')。这也意味着你的代码永远不会像id:'msgId' - 一个硬编码的ID。 – Upperstage