empty elements in tree view when load on demand

5 posts, 0 answers
  1. Elad
    Elad avatar
    4 posts
    Member since:
    Jun 2013

    Posted 02 Dec 2013 Link to this post

    Dear support,
    I am trying to load all hirarchy when user clicks on the root node via web service (web-api).
    The outcome of my code brings the correct number of elements but they are all empty (LI items with no text to display).

    the markup looks like this:
    <telerik:RadTreeView runat="Server" ID="UserGroups" Skin="Vista" DataTextField="caption" DataValueField="caption" DataFieldParentID="parentUnitCode" DataFieldID="unitCode" >
    <Nodes>
      <telerik:RadTreeNode runat="server" Text="All" ExpandMode="WebService" Value="0">
      </telerik:RadTreeNode>
    </Nodes>
    <WebServiceSettings Path="api/Reports" Method="UserGroups" UseHttpGet="True" />
    </telerik:RadTreeView>


     

     

     

    with fiddler I can see the following response when expand:

     

    JSON
         --{}
           -- Caption = "blabla"
           -- Level = 0
           -- ParentUnitCode = 0
           -- Roles
                 -- DataRoles
                      -- CDomian x = test1
                      -- CDomian y = test2
                 -- DisplayRoles
                      -- CDomian a = test1
                      -- CDomian a = test2
           -- UnitCode = 3091
     --{}
           -- Caption = "blabla2"
           -- Level = 0
           -- ParentUnitCode = 0
           -- Roles
                 -- DataRoles
                      -- CDomian x = test5
                      -- CDomian y = test6
                 -- DisplayRoles
                      -- CDomian a = test11
                      -- CDomian a = test22
           -- UnitCode = 3091

    The source of the outcome looks like this:
    <ul class="rtUL" style="height: auto; overflow: visible;">
      <LI class=rtLI _itemTypeName="Telerik.Web.UI.RadTreeNode">
      <DIV class=rtTop><SPAN class=rtSp></SPAN><SPAN class=rtIn></SPAN></DIV></LI>
      <LI class=rtLI _itemTypeName="Telerik.Web.UI.RadTreeNode">
      <DIV class="rtMid "><SPAN class=rtSp></SPAN><SPAN class=rtIn></SPAN></DIV></LI>
      <LI class="rtLI rtLast" _itemTypeName="Telerik.Web.UI.RadTreeNode">
      <DIV class=rtBot><SPAN class=rtSp></SPAN><SPAN class=rtIn></SPAN></DIV></LI>
    </ul>

    Please advise
  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 04 Dec 2013 Link to this post

    Hello Elad,

    I tried to replicate the described issue, but to no avail. This is the reason why I am sending you a sample project, demonstrating the behavior at my end. Would you give it a try at yours and let me know if the issue is still replicable. If so, please send us back the modified sample, so we could observe it locally.

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Daniel avatar
    1 posts
    Member since:
    Feb 2014

    Posted 05 Feb 2014 in reply to Nencho Link to this post

    Do you have a sample app with the RadTreeView using WebApi webservicesettings?
    <WebServiceSettings Path="api/Reports" Method="GetData" UseHttpGet="True" />
  5. Rodney King
    Rodney King avatar
    9 posts
    Member since:
    Sep 2012

    Posted 05 Feb 2014 in reply to Daniel Link to this post

    Is this even a supported option for RadTreeView? If I run this code I will get my expected data.  However, I am looking looking to get this data on demand when I select a specific node.  I seem to not be able to forward the Node to the Get method to return the specific data.  It seems as though the current methods Telerik has for using load on demand, will not work in the scenario. Am I using this the proper way?

    For my controller I have:
    public RadTreeNodeData[] Get(object context)
            {
                List<RadTreeNodeData> result = new List<RadTreeNodeData>();
                var res = Function.Tool.GetItemsRecursive("STRING ID", User.Identity.Name);
     
                if (res.Succeeded)
                {
                    foreach (var it in res.Result.OrderBy(o => o))
                    {
                        if (it.Equals("STRING ID")) continue;
     
                        RadTreeNodeData data = new RadTreeNodeData();
                        data.Text = it;
                        data.ImageUrl = Path.HasExtension(it) ? "images/txt.png" : "images/fldr.png";
                        result.Add(data);
                    }
                }
     
                return result.ToArray();
            }

    and the web form contains:
    <Telerik:RadTreeView ID="RadTreeView1" runat="server" PersistLoadOnDemandNodes="true" EnableViewState="true"
                DataFieldID="id" DataFieldParentID="parentId" DataTextField="text" CheckBoxes="true" CheckChildNodes="false" OnClientNodeChecked="OnClientNodeChecked">
                <WebServiceSettings UseHttpGet="true" Path="api/TreeView/" Method="Get"></WebServiceSettings>
     
            </Telerik:RadTreeView>
  6. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 10 Feb 2014 Link to this post

    Hello,

    I prepared a sample project that shows how you can implement load on demand functionality with RadTreeView with WebAPI. Please note that important thing is to define your routing settings in the Global.asax file as shown in the attachment. Please find the controller implementation in the App_Code folder.

    Please note that besides referencing the Telerik dlls files, RadTreeView Web API binding requires references to Newtonsoft.Json.dll, System.Net.Http.Formatting.dll, System.Web.Http.dll and System.Web.Http.WebHost.dll. In order to reduce the attachement size I removed the Telerik assemblies.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017