Webservice Fails to populate nodes correctly

3 posts, 0 answers
  1. Toby
    Toby avatar
    59 posts
    Member since:
    Jul 2009

    Posted 13 Aug 2009 Link to this post

    Hi,

    I am testing out your treeview component, using loading on demand from a webservice (as in your example) It works but the nodes created by the webservice had have no text or value when they are created, any ideas why this is happening?

    This is the webservice method, I have debugged it and node.Text and node.Value both have values when this method is processing.

            [WebMethod] 
            public RadTreeNodeData[] GetNodes(RadTreeNodeData node, object context) 
            { 
                List<RadTreeNodeData> result = new List<RadTreeNodeData>(); 
                MasterSystem aSystem = (MasterSystem)Application["MasterSystem"]; 
     
                ExtensionHierarchyObject aGroup = aSystem.ExtensionsSystem.ExtensionHierarchy._GroupFlatList.Find(delegate(ExtensionHierarchyObject g) { return g.GroupId == Convert.ToInt16(node.Value); }); 
     
                foreach (ExtensionHierarchyObject aObj in aGroup.ChildGroups) 
                { 
                    RadTreeNodeData newNode = new RadTreeNodeData();                 
                    node.Text = aObj.GroupName; 
                    node.Value = aObj.GroupId.ToString(); 
                    newNode.ExpandMode = TreeNodeExpandMode.WebService; 
                    result.Add(newNode); 
                } 
                 
                return result.ToArray();                 
            } 



            [WebMethod]
            public RadTreeNodeData[] GetNodes(RadTreeNodeData node, object context)
            {
                List<RadTreeNodeData> result = new List<RadTreeNodeData>();
                MasterSystem aSystem = (MasterSystem)Application["MasterSystem"];

                ExtensionHierarchyObject aGroup = aSystem.ExtensionsSystem.ExtensionHierarchy._GroupFlatList.Find(delegate(ExtensionHierarchyObject g) { return g.GroupId == Convert.ToInt16(node.Value); });

                foreach (ExtensionHierarchyObject aObj in aGroup.ChildGroups)
                {
                    RadTreeNodeData newNode = new RadTreeNodeData();                
                    node.Text = aObj.GroupName;
                    node.Value = aObj.GroupId.ToString();
                    newNode.ExpandMode = TreeNodeExpandMode.WebService;
                    result.Add(newNode);
                }
                
                return result.ToArray();                
            }
  2. Toby
    Toby avatar
    59 posts
    Member since:
    Jul 2009

    Posted 13 Aug 2009 Link to this post

    your example on the demos section of your website seems to be incorrect as well, if you look at it does not add the node to the list.

     Then implement the method to return the nodes that are loaded on demand. Here is a sample implementation: 
    C# 
     
    [ScriptService] 
    public class TreeViewWebService : WebService 
        [WebMethod] 
        public RadTreeNodeData[] LoadNodes(RadTreeNodeData node, object context) 
        { 
            List<RadTreeNodeData> result = new List<RadTreeNodeData>(); 
            RadTreeNodeData node = new RadTreeNodeData(); 
            node.Text = "Loaded on demand"
            node.ExpandMode = TreeNodeExpandMode.WebService; 
             
            return result.ToArray(); 
        } 
     

  3. Toby
    Toby avatar
    59 posts
    Member since:
    Jul 2009

    Posted 13 Aug 2009 Link to this post

    ignore me - just realised that on the webservice method i was refering to node instead of newnode!!

Back to Top