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

how to expand and select tree node by calling webservice explicitly

0 Answers 105 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
sanam
Top achievements
Rank 1
sanam asked on 22 Jul 2017, 07:32 PM

Hiiii,

We have a Tree view and  clicking  "+"  uses the web service . How to call the web service explicitly  to expand that node and get it selected .

<telerik:RadTreeView ID="RadTreeViewBottom" runat="server" PersistLoadOnDemandNodes="false" RegisterWithScriptManager="true" 
        LoadingStatusPosition="None" OnClientNodeClicked="RadTreeViewBottom_ClientNodeClicked"
        OnClientKeyPressing="RadTreeViewBottom_ClientKeyPressing" EnableViewState="false"
        OnClientNodePopulating="RadTreeViewBottom_ClientNodePopulating" 
        OnClientLoad="RadTreeViewBottom_OnClientLoad"
        OnClientNodeDataBound="NodeDataBound" OnClientNodeExpanded="Expanded"
        Style="white-space: normal;">
        <WebServiceSettings Method="ViewerBottom_GetNodesChildren" Path="~/ScriptServices/ScriptService.asmx" />
        <Nodes>
            <telerik:RadTreeNode Text="ExistingNode" Visible="True"/>
        </Nodes>
    </telerik:RadTreeView>

 

 

Below one is the Webmethod which i use to call in the web service

[WebMethod(EnableSession=true)]
        public RadTreeNodeData[] ViewerBottom_GetNodesChildren(RadTreeNodeData node, object context)
        {
            IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;

            int topID = int.Parse(contextDictionary["TopID"].ToString());
            string type = contextDictionary["Type"].ToString();
            int parentID = 0;

            if (node != null)
                parentID = int.Parse(node.Value);
            object[] parms = new object[3];
            parms[0] = (int)topID;
            parms[1] = type;
            parms[2] = parentID;

            global::Viewer.ViewerService.Outline outline = (ViewerService.Outline)Data.WebServiceDataProvider.GetData(Data.ViewerClientServiceWrapper.MethodName.getOutline, parms);

            ViewerService.OutlineItem[] outlineItems = outline.ChildItems;

            List<RadTreeNodeData> result = new List<RadTreeNodeData>();

            foreach (ViewerService.OutlineItem item in outlineItems)
            {
                RadTreeNodeData nodeData = new RadTreeNodeData();

                nodeData.Text = item.Title;
                nodeData.Value = item.Id.ToString();
                nodeData.Attributes.Add("DocID", item.DocumentId);

                if (item.HasChildren)
                    nodeData.ExpandMode = TreeNodeExpandMode.WebService;

                result.Add(nodeData);
            }
            return result.ToArray();
        }

 

Below is my JS 1183 is parent node and 1185 is the child node.

var node1 = parentNode.findNodeByValue("1183");
                       if (node1 == null)
                           return;
                       else {
                           node1.expand();
                           var node2 = parentNode.findNodeByValue("1185");
                           if (node2 != null) {
                               node2.select();
                           }

in JS here node2 returns me null i think  because I'm not able to Call the Webservice ecplicitly can anyone suggest me ? how to call it programatically .

 

 

 

No answers yet. Maybe you can help?

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