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

empty elements in tree view when load on demand

4 Answers 151 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Elad
Top achievements
Rank 1
Elad asked on 02 Dec 2013, 07:52 AM
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

4 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 04 Dec 2013, 03:54 PM
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.
0
Daniel
Top achievements
Rank 1
answered on 05 Feb 2014, 05:43 PM
Do you have a sample app with the RadTreeView using WebApi webservicesettings?
<WebServiceSettings Path="api/Reports" Method="GetData" UseHttpGet="True" />
0
Rodney King
Top achievements
Rank 1
answered on 05 Feb 2014, 10:37 PM
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>
0
Boyan Dimitrov
Telerik team
answered on 10 Feb 2014, 02:46 PM
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.
Tags
TreeView
Asked by
Elad
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Daniel
Top achievements
Rank 1
Rodney King
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or