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

How to binding customize nested XML to TreeView?

1 Answer 65 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Veteran
Steve asked on 11 Dec 2019, 03:26 AM

XML sample:

<?xml version="1.0" encoding="utf-8"?>
<TemplateLibrary xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" xmlns="http://www.example.org/NewXMLSchema">
  <Category name="Decks">
    <Category name="Standard Templates">
      <Category name="Deck Slabs">
        <Template name="Slab with constraints - 2 Lanes" guid="e4d44934-ff00-4c54-9de7-304896e0df45" lastRevisedDate="2015-08-31" lastRevisedBy="Sri.Kanneganti" versionMajor="1" versionMinor="32">
        </Template>
      </Category>
    </Category>
  </Category>
</TemplateLibrary>

 

my expected effect is like the attcached picture.

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 13 Dec 2019, 02:34 PM

Hello Steve,

RadTreeView can consume XML data both by directly loading it or by loading it to a DataSet for binding. These two approaches are described in the following documentation articles:
https://docs.telerik.com/devtools/winforms/controls/treeview/data-binding/binding-to-xml-data
https://docs.telerik.com/devtools/winforms/controls/treeview/data-binding/deserialize-to-xml

I reviewed the provided XML sample and it doesn't seem to be quite valid because I did not succeed in loading it successfully. In order to achieve the result shown in the picture, the XML should be as follows:

<?xml version="1.0" encoding="utf-8"?>
<TreeView xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ExpandAnimation="None" SpacingBetweenNodes="-1" AllowDrop="true" BackColor="191, 219, 255">
  <Nodes Name="Node1" Expanded="true" Text="TemplateLibrary">
    <Nodes Name="Node2" Expanded="true" Text="Decks">
      <Nodes Name="Node3" Expanded="true" Text="Standard Templates">
        <Nodes Name="Node4" Expanded="true" Text="Deck Slabs">
          <Nodes Name="Node5" Text="Slab with constratints - 2 Lanes" />
        </Nodes>
      </Nodes>
    </Nodes>
  </Nodes>
</TreeView>

I hope this information helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Treeview
Asked by
Steve
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or