TreePanel node loaded: true to have node cached.

  1. #1

    TreePanel node loaded: how to set to true to have node cached?

    Hi, I managed to pass to a TreePanel a set of nodes (as a NodeCollection), with children of each node.

    I simply use the code
    Node node = new Node();
    node.CustomAttributes.Add(record);
    node.NodeID = record.GetType().GetProperties()[0].GetValue(record, null).ToString();
    node.Icon = GetRecordIcon<T>(record);
    node.Children.AddRange(CreateTree<T>(node.NodeID, 0, "", recursiveWhere, new object[0]));
    My treePanel loads data with a store like this:

    .Store(
                        Html.X().TreeStore()
                            .Proxy(
                                Html.X().AjaxProxy()
                                    .Timeout(120000)
                                    .Url(Url.Action("/GetNodes"))
                                    .Reader(reader =>
                                        {
                                            reader.Add(Html.X().JsonReader().Root("result"));
                                        })
                                    .FilterParam("filter")
                                    .ExtraParams(p =>
                                    {
                                        p.Add(new Parameter { Name = "whereStr", Value = @ViewData["whereStr"].ToString(), Mode = ParameterMode.Value, Encode = true });
                                        p.Add(new Parameter { Name = "recursiveWhere", Value = "", Mode = ParameterMode.Value, Encode = true });
                                        p.Add(new Parameter { Name = "model", Value = @Model.GetType().ToString(), Mode = ParameterMode.Value, Encode = true });
                                        p.Add(new Parameter { Name = "initialWhereParams", Value = @JSON.Serialize(ViewData["initialWhereParams"]), Mode = ParameterMode.Value, Encode = true });
                                    })
                                    
                                  
    
                            )
    
    
                            .Root(
                                        Html.X().Node().NodeID("Root").Expanded(true)
                                    )
    
                            .Model(Html.X().Model().Fields(@ViewData["fields"] as ModelField[]))
                            .Listeners(l => {
                                l.BeforeLoad.Handler = "showLoading(this, true);";
                                l.Load.Handler = "selectFirst(this); showLoading(this, false); LOG(this.ownerTree);";
                            })
    
                    )
    Now if I pass the set of data to the treepanel, it loads correctly the first level, and make a request to the server for nodes children on node expand.
    If I collapse a node, and reexpand it, it has children not to be loaded.

    Since I load children since the first request, i would like to make the treepanel know that children are "pre-cached" and it has just to expand the node.

    I think this is related to the 'loaded' attribute inside node.data in javascript.
    If i write loaded as true, should it work, without reload children?

    If so: if I write it as CustomAttribute or CustomConfig, it goes in node.raw, not node.data.
    How can I manage to have node.data.loaded se tot true while creating the node in c#?

    Thanks!
    Last edited by millenovanta; Dec 02, 2013 at 9:34 AM.

Similar Threads

  1. Replies: 11
    Last Post: Feb 06, 2013, 5:09 PM
  2. Replies: 8
    Last Post: Jun 20, 2012, 6:48 PM
  3. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  4. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  5. Replies: 5
    Last Post: Jan 25, 2009, 7:48 AM

Tags for this Thread

Posting Permissions