2011-08-31 71 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