PDA

View Full Version : [CLOSED] TreePanel rootVisible = false problem



metci
Nov 02, 2015, 10:52 AM
Hi,

I have a treepanel and I can load data to the treeopanel successfully.But
I want to set rootVisible property of treepanel to false.When I set the rootVisible property to false,I am getting an error like Request Failure.Related screenshot is following.Despite the error, it works well.

How to overcome this.

Related code block is ;



protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ConcreteDepartmentDefinition [] l = Department.GetDepartmentList();

foreach (var obj in l)
{
if (obj.DepartmentParentOid == null || obj.DepartmentParentOid == 0)
{
Node root = new Node();
root.NodeID = obj.Oid.ToString();
root.Text = "<b>"+obj.DepartmentCode+"</b> - "+obj.DepartmentName;
root.Icon = Icon.UserHome;
root.Leaf = obj.IsLeaf;
treePanel1.Root.Add(root);
treePanel1.RootVisible = false;
}
else
{
Node newNode = new Node();
newNode.NodeID = obj.Oid.ToString();
newNode.Text = "<b>"+obj.DepartmentCode+"</b> - "+obj.DepartmentName;
newNode.Icon = Icon.UserGreen;
newNode.Leaf = obj.IsLeaf;
treePanel1.GetNodeById(obj.DepartmentParentOid.ToS tring()).AppendChild(newNode);
}
}
}

Z
Nov 04, 2015, 1:53 AM
read this. if you are accessing a variable. set the autoload to false and load it in after render.

http://forums.ext.net/showthread.php?60188-CLOSED-TreeGrid-without-root-node-cant-find-App-YYY

Thanks
/Z

metci
Nov 04, 2015, 1:53 PM
Hi @Z,

I read this.I think my problem is not related with yours,I have only a treepanel and I want to load this on pageLoad basicly.

Thanks for reply,

metci
Nov 04, 2015, 2:45 PM
Is anybody has any idea?

Daniil
Nov 05, 2015, 8:54 AM
Hello @metci,

This should be replaced with a different approach.

treePanel1.GetNodeById(obj.DepartmentParentOid.ToS tring()).AppendChild(newNode);

root.Children should be populated. As it is done here:
http://examples2.ext.net/#/TreePanel/Basic/Refresh_Static_Tree/

metci
Nov 05, 2015, 2:22 PM
Hi @Daniil,

I am sorry,but i dont understand the relation between my problem and your suggestion.I think tree what you suggest dont meet my needs.There is no hierarhy on tree.Could you explain how to find parent of child and load it.Perhaps you could send a small sample.

Normally before rootvisible is set to false,tree was working very well.After setting,it started to get request failure.

I am wating your help.

Daniil
Nov 05, 2015, 3:21 PM
Normally before rootvisible is set to false,tree was working very well.After setting,it started to get request failure.

Yes, but the GetNodeById() and AppendChild() methods should be avoided to be used during initial Page_Load. Those methods are quite designed for DirectEvents and DirectMethods.


I am sorry,but i dont understand the relation between my problem and your suggestion.I think tree what you suggest dont meet my needs.There is no hierarhy on tree.Could you explain how to find parent of child and load it.

You correctly do this:

treePanel1.Root.Add(root);

Then to add a child node to the root, you should do:

treePanel1.Root.Children.Add(node);
and so on.

To find a Node by its id, you should recursively iterate nodes' .Children starting from the root.

metci
Nov 06, 2015, 11:51 AM
Hi @Daniil,


To find a Node by its id, you should recursively iterate nodes' .Children starting from the root.

Recursively iterate action is not clear on my mind.Could you please can you send a small sample.

Thanks for advance,

metci
Nov 06, 2015, 1:29 PM
Hi @Daniil

Eventually it worked very well by using your technique.

Thank you very much.