jQuery UI Widgets Forums Lists DropDownList autoDropDownHeight problem when large data

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

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

  • jishnu2026
    Participant

    i am facing same issue on this url

    http://www.jqwidgets.com/community/topic/dropdownlist-height-issue/
    like data come from data base and populated in dropdown .
    NO ARRAY how to solve this issue using database item
    thanks


    Dimitar
    Participant

    Hello jishnu2026,

    Here is how to achieve this functionality when the dropdownlist is loaded from a data adapter (the example is based on the demo Binding to JSON Data):

    <!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.10.2.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/jqxdata.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/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
    </head>
    <body>
        <div id='content'>
            <script type="text/javascript">
                $(document).ready(function () {
                    var url = "../sampledata/customers.txt";
    
                    // prepare the data
                    var source =
                    {
                        datatype: "json",
                        datafields: [
                            { name: 'CompanyName' },
                            { name: 'ContactName' }
                        ],
                        url: url,
                        async: false
                    };
    
                    var auto = true;
                    var dataAdapter = new $.jqx.dataAdapter(source, { autoBind: true, loadComplete: function (data) {
                        if (data.length > 10) {
                            auto = false;
                        }
                    }
                    });
    
                    // Create a jqxDropDownList
                    $("#jqxWidget").jqxDropDownList({
                        selectedIndex: 0, source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25, dropDownHeight: 100, autoDropDownHeight: auto
                    });
    
                    // subscribe to the select event.
                    $("#jqxWidget").on('select', function (event) {
                        if (event.args) {
                            var item = event.args.item;
                            if (item) {
                                var valueelement = $("<div></div>");
                                valueelement.text("Value: " + item.value);
                                var labelelement = $("<div></div>");
                                labelelement.text("Label: " + item.label);
    
                                $("#selectionlog").children().remove();
                                $("#selectionlog").append(labelelement);
                                $("#selectionlog").append(valueelement);
                            }
                        }
                    });
                });
            </script>
            <div id='jqxWidget'>
            </div>
            <div style="font-size: 12px; font-family: Verdana;" id="selectionlog">
            </div>
        </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.