hello
Im using tree with loadFilter:
<ul id="t" class="easyui-tree" data-options="
url:'../retrieve/get.php',
method:'get',
animate:true,
lines:true,
loadFilter:treeFilter"></ul>
function treeFilter(rows,parent){
for(var i=0; i<rows.length; i++){
rows[i]['text'] = rows[i]['name'];
}
var nodes = [];
// get the top level nodes
for(var i=0; i<rows.length; i++){
var row = rows[i];
if (!row._parentId){
nodes.push(row);
rows.splice(i,1);
i--;
}
}
var toDo = [];
for(var i=0; i<nodes.length; i++){
toDo.push(nodes[i]);
}
while(toDo.length){
var node = toDo.shift(); // the parent node
// get the children nodes
for(var i=0; i<rows.length; i++){
var row = rows[i];
if (row._parentId == node.id){
if (node.children){
node.children.push(row);
} else {
node.children = [row];
}
toDo.push(row);
rows.splice(i,1);
i--;
}
}
}
return nodes;
}
the data shows properly, but when I try to append a child node, the node always apear in the same level of root:
var node = $('#t').tree('getSelected');
$('#t').tree('append', {
_parentId: node.id,
data: [{
id: 11,
name: 'new_name'
}]
});
I think " _parentId " is not been recognized and the node always take no parent as the root node
example:
-- root (id:1)
---- folder (id:2) <--------- append node "new"
------- file (id:3)
should be:
-- root (id:1)
---- folder (id:2)
------- file (id:3)
------- new (id:4)
instead I get:
-- root (id:1)
---- folder (id:2)
------- file (id:3)
-- new (id:4)
What Im trying to said is that "new" should by child of "folder" not on the same level of "root"
In the data base is saved properly and when I reload the tree "new" is in the right place
But I dont want/can reload the tree for this particulary case
some idea?
thanks