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

Cannot grok this...

1 Answer 36 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 06 Jan 2014, 03:25 PM

Followup: Found this:

http://www.telerik.com/help/aspnet-ajax/treeview-data-binding-hierarchical.html



which answered my question, and was able to resolve my issue.



Sometimes, admittedly, I am not the brightest bulb on the planet, but for the life of me I just can't seem to get what I think is a rather simple TreeView to work.


I have data from an SQL data source which is broken down into categories, i.e.







ID              Text                    ParentId
-----------------------------------------------------------
Header                                  Header
Preamble                                Preamble
Clauses                                 Clauses
            Administrative Fees     Clauses
            Prompt Delivery         Clauses
Signature Block                         Signature Block
Appendix                                Appendix
Exhibit                                 Exhibit








Basically, I want this to appear in a tree view with the "Id" Text being the primary (expandable) node (i.e. Clauses), and the "text" being the secondary node which will appear when the user expands the primary node.







I've fiddled around w/ the various online examples, but either I get an error telling me "These columns don't currently have unique values" (if I leave the ParentId column blank when the Text column is blank) or I get nothing at all. I've tried duplicating the online example:







<telerik:RadTreeView runat="server" ID="RadTreeView1" DataSourceID="SqlDataSource1"
DataFieldID="id" DataFieldParentID="parentID" Skin="Vista" CheckBoxes="true">
    <DataBindings>
        <telerik:RadTreeNodeBinding TextField="Text" />
        <telerik:RadTreeNodeBinding
            Depth="0"
            Checkable="false"
            TextField="Text"
            Expanded="true"
            CssClass="rootNode"
        />
    </DataBindings>
</telerik:RadTreeView>








but without "seeing" the underlying data, I'm not sure how to structure my dataset to duplicate this functionality.







Can someone provide a simple example of the proper TreeView syntax?











1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 08 Jan 2014, 01:47 PM
Hello Michael,

In order to run the online demo example, you need to create an SQL database with a table named Links. The structure of the table may be seen in the attached SqlTableStructure.jpg file.
The SqlTableContent.jpg file shows the sample data used in the demo.

As the table content picture shows, the ID column should have unique values for each row.

The ParentId column should have value NULL for all root level items.

The Text column holds the text that is displayed in the TreeView.

In the SampleSolutionStructure.jpg file attached, I have suggested a sample SQL Table content for your case.

You may use the Binding to Hierarchical Data documentation article for further clarification of the SQL table structure and the resulting TreeView.

Regards,
Dimitar
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.
Tags
TreeView
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Answers by
Dimitar
Telerik team
Share this question
or