標籤:des style blog color io ar div sp cti
ExtJs 中預設對樹節點表徵圖控制的CSS代碼:
1 .x-tree-icon-leaf{width:16px;background-image:url(‘../../resources/themes/images/default/tree/leaf.gif‘)}2 .x-tree-icon-parent{width:16px;background-image:url(‘../../resources/themes/images/default/tree/folder.gif‘)}3 .x-grid-tree-node-expanded .x-tree-icon-parent{background-image:url(‘../../resources/themes/images/default/tree/folder-open.gif‘)}
對樹節點的表徵圖的改變:
1、擷取樹節點
可以在後台先列印出來節點
var store = Ext.create(‘Ext.data.TreeStore‘, { root: { id : ‘root‘ , text : ‘我的tree‘ , expanded: true, //這個children是一個數組 children: [ { id : ‘c1‘ , text: "1", expanded: true, children: [ {id : ‘c1‘ ,text: "11", leaf: true }, {id : ‘c2‘ , text: "22", leaf: true} ] }, { id : ‘c2‘ , text: "2", expanded: true, children: [ {id : ‘c3‘ , text: "33", leaf: true }, {id : ‘c4‘ , text: "44", leaf: true} ] }, { id : ‘c3‘ , text: "3", expanded: true, children: [ {id : ‘5‘ , text: "55", leaf: true }, {id : ‘6‘ , text: "66", leaf: true} ]} ] }});var testTree = Ext.create(‘Ext.tree.Panel‘, { title: ‘導航樹‘, width: 200, height: 800, store: store, rootVisible: true, lines : true , //設定lines為false, TreePanel將會隱藏折線. useArrows : false , //隱藏折線,並且顯示出一個箭頭表徵圖.// iconcls : renderTo : Ext.getBody()});
if(message.type == ‘change_icon‘){ // testTree .settreeCls(‘user-online‘); //var rootNode = treestore.getRootNode(); //var root = rootNode.childNodes; //console.log(testTree.getRootNode().get(‘id‘)); //console.log(testTree.id); //console.log(testTree); //console.log(testTree); /* testTree testTree.setIconCls(‘user-online‘);*/ }
/** * treeNode ext TreeNode對象 * oldIconCls 原表徵圖css名 * newIconCls 新表徵圖css名 */ function updateTreeNodeIcon(treeNode,oldIconCls,newIconCls){ if(!treeNode) return; /*獲得樹節點<Img> html頁面元素對象*/ var imgHtmlEl = treeNode.getUI().getIconEl(); /*設定樹節點新表徵圖css*/ treeNode.iconCls = newIconCls; Ext.Element.fly(imgHtmlEl).removeClass(oldIconCls);// @1 Ext.Element.fly(imgHtmlEl).addClass(newIconCls); }
Extjs 樹節點樣式改變