initial load as lazy load

5 posts, 0 answers
  1. Doug
    Doug avatar
    68 posts
    Member since:
    Aug 2014

    Posted 01 Aug 2014 Link to this post

    i am trying to change my tree to a load after the page loads of the initial tree (and perhaps a selected node in tree)
    I currently have my tree working with webservice and the initial load loads in enough branches to a preselected node if a querystring of that category is present.
    else it loads in the top folders.

    what I want to do is use javascript on the load of the tree to initiate a loading of the tree.
    in my control I have OnClientLoad="DoLoadTree" and a webservice of
    WebServiceSettings Path="/DesktopModules/DocumentTree/TreeViewWebService.asmx" Method="GetTreeViewCategories"

    my js function I am trying to call into the webservice with the top tree item for it to start adding in the nodes
    ​function DoLoadTree(){
    var treeView = $find("<%=RadTreeView1.ClientID %>");

    I can create a node if I wanted to but still cant see how to tell that node to have the + sign
    and I cannot see how to tell that node or that tree parent to call into the webservice.
  2. Doug
    Doug avatar
    68 posts
    Member since:
    Aug 2014

    Posted 01 Aug 2014 in reply to Doug Link to this post

    ok I was finally able to get my initial node to work and call into the web service.
    but what I would like to do is to just set a value to the top tree control and call into the web service with that control.

    the only other way I can see to do this is using js to do a server call to get the values for the top level nodes, and a path to the correct tree value so I can call the expanding from the correct node.
    for instance my top level may have 5 categories listed and the preselect might be located under node 4 a few levels deep.

    I am thinking if I can add a value to the top tree and call into the function then perhaps I can do everything in web service.

    another possible solution may be to create a dummy node and call into web service and have it change the dummy node to the corrected value? and would need to add brothers to the same parent (top tree control). this sounds feasible to me and I already have the code to make the call for this - I will test this out.

    so I am asking if there is a way to call into the webservice with just the top tree control (no nodes) and some initial data.



  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 06 Aug 2014 Link to this post

    Hello,

    As far as I understand you want simply to call a web service method explicitly from the client-side and pass some value as parameter to the service. I would suggest reviewing this help article that explains how to add a web service in your script manager in order to call the service from the client-side.

    Also you can make a separate method in your web service implementation that will expect the value argument and return the data you need. In other words you do not need to call the method declared in the RadTreeView web service section since this method expects a node object and context. 


    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Doug
    Doug avatar
    68 posts
    Member since:
    Aug 2014

    Posted 06 Aug 2014 in reply to Boyan Dimitrov Link to this post

    I understand and will presue this method.
    is there an easy way to have the webservice return the RadTreeNodeData and just tie it directly to the top tree object?

    I am sure I could eventually work out how to turn it into a js node object and add in that way each item in the returned array from the webservice but is there a quick way to do it?
  6. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 11 Aug 2014 Link to this post

    Hello,

    The code snippet below shows an example of web service method that will return collection of RadTreeNodeData to the client-side.
    //code behind
    [WebMethod]
        public RadTreeNodeData[] LoadNodes(string text)
        {
            List<RadTreeNodeData> result = new List<RadTreeNodeData>();
            RadTreeNodeData node = new RadTreeNodeData();
            node.Text = "Loaded on demand";
            node.ExpandMode = TreeNodeExpandMode.WebService;
             
            return result.ToArray();
        }

    In order to add a node to the RadTreeView on the client-side you have to create a RadTreeNode as shown below:
    //JavaScript
    var node = new Telerik.Web.UI.RadTreeNode();

    Please refer to this help article for more information.

    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017