How can I change the attributes of a tree node?
One tree node has the following attributes:
{"id":"75",
"description":"My Tree Node",
"status":"25"
"uiProvider":"col",
"leaf":true}
Now my script receives the following data
{
"id":"75",
"status":"100",
"cls":"done"
}
I try to update the attributes (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];
}
The tree, however, does not get updated.
How can I make the tree show the changes? I need the node to change existing attributes and add the new attributes.
I appreciate your help!
How can I change the attributes of a tree node?
One tree node has the following attributes:
{"id":"75",
"description":"My Tree Node",
"status":"25"
"uiProvider":"col",
"leaf":true}
Now my script receives the following data
{
"id":"75",
"status":"100",
"cls":"done"
}
I try to update the attributes (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];
}
The tree, however, does not get updated.
How can I make the tree show the changes? I need the node to change existing attributes and add the new attributes.
I appreciate your help!
Share Improve this question edited Oct 7, 2009 at 21:02 Alex L asked Oct 7, 2009 at 18:36 Alex LAlex L 8,4496 gold badges44 silver badges52 bronze badges 1- a.result.data.property might be a bad way to access it.. getting undefined – Alex L Commented Oct 7, 2009 at 20:51
1 Answer
Reset to default 2From the extjs forums:
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;
}
}
Should work if you call it after your update loop.