jQuery UI Widgets Forums Navigation Tree Restrict selection on Parent Item

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 8 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Restrict selection on Parent Item #81447

    Vinay Reddy
    Participant

    Hi,

    Can i know weather there is support to restrict selection on a parent item of tree.

    Child1
    — John
    — Brown
    Child2
    — Micheal
    — Chris

    Now i want to restrict selection on Child1 and Child2.

    Please help me on this.

    Thanks,
    Vinay Reddy

    Restrict selection on Parent Item #81449

    Dimitar
    Participant

    Hi Vinay Reddy,

    Please refer to the following example. It shows how to disable the selection of root-level items.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxtree.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxexpander.js"></script>
        <script type="text/javascript">
            $(document).ready(function ()
            {
                $('#jqxTree').jqxTree({
                    height: '300px',
                    width: '300px',
                    theme: 'energyblue'
                });
                $('#jqxTree').on('select', function (event)
                {
                    var args = event.args;
                    var item = $('#jqxTree').jqxTree('getItem', args.element);
                    if (item.level === 0)
                    {
                        $("#jqxTree").jqxTree('selectItem', null);
                        return;
                    }
                    var label = item.label;
                    alert("You selected " + label);
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxTree'>
            <ul>
                <li>Home</li>
                <li item-expanded='true'>Solutions
                    <ul>
                        <li>Education</li>
                        <li>Financial services</li>
                        <li>Government</li>
                        <li>Manufacturing</li>
                        <li>Solutions
                            <ul>
                                <li>Consumer photo and video</li>
                                <li>Mobile</li>
                                <li>Rich Internet applications</li>
                                <li>Technical communication</li>
                                <li>Training and eLearning</li>
                                <li>Web conferencing</li>
                            </ul>
                        </li>
                        <li>All industries and solutions</li>
                    </ul>
                </li>
            </ul>
        </div>
    </body>
    </html>

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.