This is a migrated thread and some comments may be shown as answers.

Webservice Fails to populate nodes correctly

2 Answers 49 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Toby
Top achievements
Rank 1
Toby asked on 13 Aug 2009, 01:08 PM
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 Answers, 1 is accepted

Sort by
0
Toby
Top achievements
Rank 1
answered on 13 Aug 2009, 01:15 PM
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(); 
    } 
 

0
Toby
Top achievements
Rank 1
answered on 13 Aug 2009, 01:59 PM
ignore me - just realised that on the webservice method i was refering to node instead of newnode!!

Tags
TreeView
Asked by
Toby
Top achievements
Rank 1
Answers by
Toby
Top achievements
Rank 1
Share this question
or