[CLOSED] TreePanel : "invalid property id" error

  1. #1

    [CLOSED] TreePanel : "invalid property id" error

    Hello,

    We are using DirectMethod to load nodes of TreePanel from database:

             [DirectMethod]
            public string LoadTree()
            {
                Ext.Net.TreeNodeCollection nodes = new Ext.Net.TreeNodeCollection();
                Ext.Net.TreeNode root = new Ext.Net.TreeNode("Root");
                nodes.Add(root);
    
                List<VW_ORG_STRUCTURE> orgTree = OrgStructureDb.GetAllItems();
                //recursevly add all nodes under the root starting with first level (i.e. PARENT_LIST_ITEM_ID == null)
                AddNodes(root, orgTree.Where(t => t.PARENT_ID == null).ToList(), orgTree);
    
                return nodes.ToJson();
            }

    AddNodes create node this way:
                    // Create the new node.
                    Ext.Net.TreeNode childNode = new Ext.Net.TreeNode(li.ENTITY_ID.ToString(), li.ENTITY_NAME, Icon.Application);
                    //the line below is just to test if using NodeID property explicitly resolves the problem - it didn't
                    childNode.NodeID = li.ENTITY_ID.ToString();
                    childNode.CustomAttributes.Add(new ConfigItem("EntityType", li.ENTITY_TYPE_ID.ToString()));
                    parent.Nodes.Add(childNode);
    On the client we have this error (taken from FireBug):

    invalid property id
    [{,children:[{id:"1",iconCls:"icon-app...pplication",text:"JV",EntityType:1}]}]


    Note, that there is no 'NodeId' property in JSON, but 'id' instead and that's exactly what error description says.
    Do you see anything wrong with populating tree and passing it back to client through JSON in our case?

    Much appreciated your help!
    Last edited by Daniil; Aug 02, 2011 at 1:56 PM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Hi,

    Note, that there is no 'NodeId' property in JSON, but 'id' instead and that's exactly what error description says.
    It's normal, NodeId is rendered as "id".

    Do you see anything wrong with populating tree and passing it back to client through JSON in our case?
    Well, it looks without errors.

    But how do you use that DirectMethod?

    Could you provide us with a full example?
  3. #3
    Hi Daniil,

    We call direct method from the js, here is the function that calls LoadTree() on the server:

    function loadReAssignTree(node) {
                var tree = MainContent_tpReAssignNode;
                Ext.net.DirectMethods.LoadTree({
                    success: function (result) {
                        var nodes = eval(result);
                        if (nodes.length > 0) {
                            tree.initChildren(nodes);
                        }
                        else {
                            tree.getRootNode().removeChildren();
                        }
                    }, 
                    failure: function (errorMsg) {
                        Ext.Msg.alert('Failure', errorMsg);
                    }
    
                });
    }
    Do we call it in the right way?
    Let me know if you need more pieces as to give you full page I have to strip all unrelated logic.
    Thanks,
    oleg
    Last edited by Daniil; Jul 22, 2011 at 5:35 PM. Reason: Please use [CODE] tags
  4. #4
    Are you basing on this example?
    https://examples1.ext.net/#/TreePane...Method_Loader/

    Why don't you want to do the same?

    .initChildren() is not for public usage, it's a private method.
  5. #5
    Not quite. That example uses TreePanel root defined in aspx page and it uses AsyncTreeNode type on the server. Our project requires to show multiple roots and I couldn't make it with setup in that example. I have to omit root in aspx and create it on server using TreeNode type (see code below) and use TreePanel's RootVisible="false" to suppress first level dummy root

            [DirectMethod]
            public string RefreshOrgSturctureTree()
            {
                //workaround to show multiple roots
                Ext.Net.TreeNodeCollection nodes = new Ext.Net.TreeNodeCollection(true);
                Ext.Net.TreeNode root = new Ext.Net.TreeNode("0", "dummyRoot", Icon.Application);
                Ext.Net.TreeNodeCollection nodes2 = this.PopulateOrgTree();
                root.Nodes.AddRange(nodes2);
                nodes.Add(root);
                return nodes.ToJson();
            }
                    <ext:TreePanel 
                        ID="tpOrgSturcture"
                        runat="server" 
                        Height="500" 
                        Width="300"
                        UseArrows="false"
                        AutoScroll="true"
                        Animate="false"
                        EnableDD="false"
                        HideParent="true"
                        RootVisible="false" 
                        AllowLeafDrop="false" 
                        ContainerScroll="true"
                        Lines="true"
                        >
    Having said that, replacing ...
    var data = eval(result);
    ... with ....
    var data = eval("(" + result + ")");
    ... seems to fixed the original "invalid property id" error. The only thing remaining is node.loadNodes(data); function call in that example (relevant funciton below).

            function nodeLoad(node) {
                Ext.net.DirectMethods.NodeLoad(node.id, {
                    success: function (result) {
                        var data = eval("(" + result + ")");
                        node.loadNodes(data);
                    },
    
                    failure: function (errorMsg) {
                        Ext.Msg.alert('Failure', errorMsg);
                    }
                });
    'node' is passed from the tree in that example (is that root by the way?), but we don't have root defined statically and I don't see loadNodes() function on tree or tree.root in FireBug debugger.

    How we should properly call loadNodes() then?
    What is the danger to stick with tree.initChildren(nodes) as it's working currently?

    Thanks,
    oleg
  6. #6
    Quote Originally Posted by coleg123 View Post
    'node' is passed from the tree in that example (is that root by the way?), but we don't have root defined statically and I don't see loadNodes() function on tree or tree.root in FireBug debugger.

    How we should properly call loadNodes() then?
    What is the danger to stick with tree.initChildren(nodes) as it's working currently?
    Yes, there is a root in that example, but .loadNodes() doesn't require a root node as an argument, it works with another nodes as well.

    I can't see how you create a tree with its root node.

    Well, generally speaking, .initChildren() can work in public usage, but just be careful to use it.

    I'd prefer to use .loadNodes().

    If you will in trouble with it further, it would be best to provide us with a full sample which we can run and see the problem.

Similar Threads

  1. Replies: 7
    Last Post: Dec 19, 2013, 7:16 PM
  2. Replies: 6
    Last Post: Jul 03, 2012, 5:46 PM
  3. Replies: 1
    Last Post: Jun 26, 2012, 11:29 AM
  4. Replies: 1
    Last Post: Mar 13, 2011, 9:21 AM
  5. [CLOSED] IE8 combo "Invalid argument" on z-index
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2011, 10:10 AM

Tags for this Thread

Posting Permissions