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

treeview in listview template

3 Answers 294 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ziff
Top achievements
Rank 1
Ziff asked on 21 Nov 2018, 02:50 AM

Hi,

I am using KendoUI for javascript angular directive. I have a list of tree object like:

dc.DataSource=[{Name:"Item1",Children:[{Name:"Item1.1"},{Name:"Item1.2"}]},

 {Name:"Item2",Children:[{Name:"Item2.1"},{Name:"Item2.2"}]}

];

What I want to achieve is show each object in datasource in a listview template, and inside the template, I want to use tree view to display the hierarchical data(and a checkbox for each item data). In below code, I just want to know how to set the datasource of the treeview since it is different for each item

<div kendo-list-view k-data-source="dc.DataSource">
        <div k-template>
            <div class="col-md-3">
                <div kendo-tree-view="tree"  k-data-source="{{dataItem}}">
                    <span k-template>
                        {{dataItem.Name}}
                    </span>
                </div>
            </div>
        </div>
    </div>

Thanks,

Ziff

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 22 Nov 2018, 03:29 PM
Hi Ziff,

The following dojo example demonstrates how to populate a TreeView with the item bound to the ListView item, but please note that the children collection of the TreeView dataSource must be named "items":
If further assistance on this matter is needed, please do not hesitate to contact us again.


Regards,
Konstantin Dikov
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.
0
Ziff
Top achievements
Rank 1
answered on 24 Nov 2018, 02:54 AM

Hello,

Thanks for your advice and it works now. I have a future request that I need show checkbox for each item. My datasource for listview has a "checked" property so when listview and treeview is initial displayed, some of the nodes are already checked. My problem is after user check/uncheck items,  how can I update it back to datasource. 

Thanks,

Ziff

 

0
Viktor Tachev
Telerik team
answered on 28 Nov 2018, 10:08 AM
Hi Ziff,

In order to have the TreeView with checkboxes I would suggest using configuration similar to the one illustrated in the example below:


Also check out the modified dojo for reference:



Regards,
Viktor Tachev
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
ListView
Asked by
Ziff
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Ziff
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or