MVC5 Classic
Use Check Boxes

The wijtree widget allows you to display tree nodes with check boxes. This topic will walk you through setting the correct property to display check boxes. See the Check Box > Tree sample of the MVC Control Explorer live demos at http://demo.componentone.com/ASPNET/MVCExplorer/tree/Checkbox.

  1. Create an C1 ASP.NET MVC 5 Web Application.
  2. In the Solution Explorer, expand the Views | Shared folder and double-click _Layout.cshtml to open the file.
  3. Add the following markup within the <body> tags of the page.
    <div>
            <ul id="tree">
                <li class="folder"><a><span>Folder 1</span></a>
                    <ul>
                        <li class="folder"><a><span>Folder 1.1</span></a>
                            <ul>
                                <li class="file"><a><span>File 1.1</span></a></li>
                                <li class="file"><a><span>File 1.2</span></a></li>
                                <li class="file"><a><span>File 1.3</span></a></li>
                                <li class="file"><a><span>File 1.4</span></a></li>
                                <li class="file"><a><span>File 1.5</span></a></li>
                            </ul>
                        </li>
                        <li class="file"><a><span>File 1.2</span></a></li>
                        <li class="file"><a><span>File 1.3</span></a></li>
                        <li class="file"><a><span>File 1.4</span></a></li>
                        <li class="file"><a><span>File 1.5</span></a></li>
                    </ul>
                </li>
                <li class="folder"><a><span>Folder 2</span></a>
                    <ul>
                        <li class="file"><a><span>File 2.1</span></a></li>
                        <li class="file"><a><span>File 2.2</span></a></li>
                        <li class="file"><a><span>File 2.3</span></a></li>
                        <li class="file"><a><span>File 2.4</span></a></li>
                        <li class="file"><a><span>File 2.5</span></a></li>
                    </ul>
                </li>
                <li class="folder"><a><span>Folder 3</span></a>
                    <ul>
                        <li class="file"><a><span>File 3.1</span></a></li>
                        <li class="file"><a><span>File 3.2</span></a></li>
                        <li class="file"><a><span>File 3.3</span></a></li>
                        <li class="file"><a><span>File 3.4</span></a></li>
                        <li class="file"><a><span>File 3.5</span></a></li>
                    </ul>
                </li>
            </ul>
        </div>
    
  4. Insert the following script to initialize the widget. Note that the showCheckBoxes and allowEdit properties are both set to "true".
    <script id="scriptInit" type="text/javascript">
            $(document).ready(function () {
                var tv = $("#tree").wijtree({
                    showCheckBoxes: true,
                    allowEdit: true
                });
            });
        </script>
    
  5. Run your program. The widget should resemble the following image:

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback