changing the tree nodes background colour in extjs4 -
i new js please forgive me if asking basic question.
i want change background colour of node in tree have here.
ext.application({ name: 'autopsy', launch: function() { ext.create('ext.container.viewport', { layout: 'border', items:[ { ...... ....... }, { region:'west', collapsible: true, resizable: true, title: 'threads (total: {{ num_threads|replace("\n","\\n") }})', width: 200, layout: 'fit', items: [ { xtype: 'treepanel', rootvisible: false, store: threadstore, lines: false, usearrows: true, } ] }, { ..... .....
threadsotre is
var threadstore = ext.create('ext.data.treestore', { root: { text: 'root', expanded: true, children: [ {% thread in threadids %} { text: "thread {{ thread }}", leaf: true }, {% endfor %} { text: "thread ex", expanded: true, children: [ { text: "functop", leaf: true }, { text: "funcbottom", leaf: true}, { text: "test", leaf: true} ] }, ] } });
this give me output below
thread 6
thread 5
thread 4
thread 3
thread 2
thread 1
i want ground color of "thread 1" red. how can ?
you can use treecolumn renderer change style of node. sample code follows.
xtype: 'treepanel', rootvisible: false, store: threadstore, lines: false, usearrows: true, columns: [{ xtype : 'treecolumn', text: 'email', dataindex: 'name', flex: 1, renderer: function (value, metadata) { //todo apply logic here... if(value==='thread1'){ metadata.tdattr = 'bgcolor="red"'; } return value; } }
Comments
Post a Comment