[英]Extjs: How to change tree node attributes?
如何更改樹節點的屬性?
一個樹節點具有以下屬性:
{"id":"75",
"description":"My Tree Node",
"status":"25"
"uiProvider":"col",
"leaf":true}
現在我的腳本收到以下數據
{
"id":"75",
"status":"100",
"cls":"done"
}
我嘗試更新屬性( UPDATED ):
// a.result.data has the new data and taskID is the node's id
for (var property in a.result.data)
{
tree.getNodeById(taskID).attributes[property] = a.result.data[property];
}
但是,該樹不會更新。
如何使樹顯示更改? 我需要該節點來更改現有屬性並添加新屬性。
我感謝您的幫助!
從extjs論壇 :
function refreshNodeColumns(n)
{
var t = n.getOwnerTree();
var a = n.attributes;
var cols = t.columns;
var el = n.ui.getEl().firstChild; // <div class="x-tree-el">
var cells = el.childNodes;
//<div class="x-tree-col"><div class="x-tree-col-text">
for(var i = 1, len = cols.length; i < len; i++)
{
var d = cols[i].dataIndex;
var v = (a[d]!=null)? a[d] : '';
if (cols[i].renderer) v = cols[i].renderer(v);
cells[i].firstChild.innerHTML = v;
}
}
如果在更新循環后調用它應該可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.