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

Check-boxes not working with Unordered List

3 Answers 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 17 Sep 2013, 11:46 AM
Hi,

I've an unordered list of items which is convert to a Treeview. I want my tree to be have drag and drop functionality as well as check-boxes to unable multiple selection. Drag and drop is working perfectly but when i try to use check-boxes, check-boxes just dont show up. Due to project complexity i can't use data source to bind to treeview, it has to be unordered list. The List is not static, items are added at runtime. Kendo version used: 2013.2.716

Below is the sample code:
<div id="example" class="k-content">
            <div class="demo-section">
                <ul id="treeview">
                    <li data-expanded="true">
                        <span class="k-sprite folder"></span>
                        My Web Site
                        <ul>
                            <li data-expanded="true">
                                <span class="k-sprite folder"></span>images
                                <ul>
                                    <li><span class="k-sprite image"></span>logo.png</li>
                                    <li><span class="k-sprite image"></span>body-back.png</li>
                                    <li><span class="k-sprite image"></span>my-photo.jpg</li>
                                </ul>
                            </li>
                            <li data-expanded="true">
                                <span class="k-sprite folder"></span>resources
                                <ul>
                                    <li data-expanded="true">
                                        <span class="k-sprite folder"></span>pdf
                                        <ul>
                                            <li><span class="k-sprite pdf"></span>brochure.pdf</li>
                                            <li><span class="k-sprite pdf"></span>prices.pdf</li>
                                        </ul>
                                    </li>
                                    <li><span class="k-sprite folder"></span>zip</li>
                                </ul>
                            </li>
                            <li><span class="k-sprite html"></span>about.html</li>
                            <li><span class="k-sprite html"></span>contacts.html</li>
                            <li><span class="k-sprite html"></span>index.html</li>
                            <li><span class="k-sprite html"></span>portfolio.html</li>
                        </ul>
                    </li>
                </ul>
            </div>
            <script>
                $(document).ready(function () {
                    $("#treeview").kendoTreeView({
                        dragAndDrop: true,
                        checkboxes: {
                            checkChildren: true
                        }
                    });
                });
            </script>
        </div>

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 19 Sep 2013, 10:19 AM
Hello Sunil,

The check boxes are not shown because the unordered list is already rendered, however you can redraw the TreeView as shown in this example.
 
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ronald
Top achievements
Rank 1
answered on 24 Mar 2014, 03:05 PM
In the redraw example mentioned above the root node ("My Web Site") is not having a checkbox. Can you extend the example so the root node also gets a checkbox? 

Thanks
0
Alexander Popov
Telerik team
answered on 26 Mar 2014, 12:19 PM
Hi Ronald,

Displaying checkboxes in a TreeView initialized from a ul element is currently not supported out of the box. Implementing this behavior would require a custom solution, more complicated than the workaround I previously suggested. That is why I would recommend initializing the TreeView from a div element and using a HierarchicalDataSource, as shown in this demo.

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