XUL treecol親ノードのテキスト
できた。子ノードのデータを持ってるやつと、テキストラベルを分離する必要がある。
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <tree flex="1" id="obj-tree" primary="true" > <treecols> <treecol id="key-col" label="Key" primary="true" flex="1" /> <splitter class="tree-splitter"/> <treecol id="value-col" flex="1" label="Value" /> </treecols> <treechildren/> </tree> <script src="tree-utils.js"/> <script><![CDATA[ var obj = { a : { b : { e : {}, }, d : true, }, c : 500, d : 'VALUE' } var share = {}; function isEmpty(obj){ for(var i in obj) return false; return true; } function Record (key, value){ this.setColumnPropertyName('key-col', 'key'); this.setColumnPropertyName('value-col', 'text'); this.key = key; this.value = value; this.text = value; if(typeof(value)=='object' && !isEmpty(value)) { this.text = ''; this.reserveChildren(); } } Record.prototype = new TreeOViewRecord(share); Record.prototype.onPreOpen = function(){ var obj = this.value; for(var key in obj) this.appendChild (new Record(key, obj[key])); this.onPreOpen = function(){}; } var view = new TreeOView(share); view.childData.appendChild(new Record('root', obj)); var tree = document.getElementById("obj-tree"); tree.treeBoxObject.view = view; ]]></script> </window>
valueがobjectのときはテキストを空白に。空白以外がよければなにか書けばよろし。
cview-trees.jsみて、実際入れてみて(へんな位置にcviewのメニューが増えてて気がつかなかった)やっときがついた。