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

TreeView - Binding to remote data - How to bind when parent and child datafield is different

1 Answer 214 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 14 May 2013, 12:28 PM
I m using MVC 4 and trying bind to database using below sample

@(Html.Kendo().TreeView()
.Name("treeview")
.HtmlAttributes(new {@class="demo-section" })
.DataTextField("Table")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("GetData", "TreeView")
)))

but I can't get it work because my data is like
- Table1 (Table)
   - Column1.1 (Column)
   - Column1.2
- Table2
   - Column2.1 
   - Column2.2

When i use .DataTextField("Table"), I only manage to get parent tree view without child.
I wonder how to put in DataTextField since parent field is Table while child field is Column.

Please help!

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 15 May 2013, 09:06 AM
Hi Dan,


The TreeView cannot be initialized correctly if the text field is different for the parent and the child items. As a workaround I would suggest you to extract a projection of your data as a ViewModel, in which the DataTextField property should be the same for all items.

I hope this approach will work for the current scenario.

 

Regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Dan
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or