我有个树的组件,我想根据某个条件来动态的修改被选中的节点的图标,我试了很多方法,都不行,没有办法了,求 救
1条回答 默认 最新
- zhoujuan520 2009-07-21 12:46关注
我查看了api确实没有像对应的方法,只有setText(),因为这个图标都是在组建生成的时候一起生成的,不过你可以通过另个变态一点的方法解决
[code="js"]treePanel.on('click',function(n){
n.getUI().getIconEl().src = '../../images/icons/checked.png';
});[/code]
节点有下列方法
getUI() : TreeNodeUI
Returns the UI object for this node. //返回这个节点的UI对象然后你去看TreeNodeUI的api
他里面提供了两个方法
getIconEl() : HtmlElement 获得图片的那个对象
Returns the icon element.
Parameters:* None.
Returns:
* HtmlElement The DOM image element.
getTextEl() : HtmlNode 这个获得文本的那个对象
Returns the text node.Parameters:
* None.
Returns:
* HtmlNode The DOM text node.
然后你就可以通过图片的src属性来动态改变图片了
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1