Posted on 2009-07-01 21:26
月下孤城 閱讀(4001)
評論(1) 編輯 收藏 所屬分類:
extjs
需求說明:
最近項(xiàng)目有個實(shí)現(xiàn)web Im的需求,我們知道對于聊天用戶中人員在上下線時,用戶圖標(biāo)會呈現(xiàn)不同的狀態(tài)。為給用戶好的體驗(yàn),
在用戶下線時需實(shí)現(xiàn),1.用戶信息置灰;2.換上線圖標(biāo)為下線圖標(biāo).
代碼實(shí)現(xiàn):
/**
* treeNode ext TreeNode對象
* oldIconCls 原圖標(biāo)css名
* newIconCls 新圖標(biāo)css名
*/
function updateTreeNodeIcon(treeNode,oldIconCls,newIconCls){
if(!treeNode)
return;
/*獲得樹節(jié)點(diǎn)<Img> html頁面元素對象*/
var imgHtmlEl = treeNode.getUI().getIconEl();
/*設(shè)置樹節(jié)點(diǎn)新圖標(biāo)css*/
treeNode.iconCls = newIconCls;
Ext.Element.fly(imgHtmlEl).removeClass(oldIconCls);// @1
Ext.Element.fly(imgHtmlEl).addClass(newIconCls);
}
說明:注意在上面代碼'@1'處刪除'原圖標(biāo)css'時先要轉(zhuǎn)換html對象(imgHtmlEl)為ext中的Element對象.樹節(jié)點(diǎn)圖標(biāo)替換后,可以使用TreeNode
disable()/enable()方法使節(jié)點(diǎn)置灰/正常狀態(tài).
---------------------
月下孤城
mail:eagle_daiqiang@sina.com