jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList group-function with json-data for drop down list

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by  jan 11 years, 2 months ago.

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

  • Robert Jaeger
    Participant

    I am successfully using json data for a drop down list. But now I want to use the group function. I found a static example in the documentation, I would like to know how to define groups for a drop down list with json data.

    I cannot find the property to set the item’s group when creating the drop down list: .jqxDropDownList( group? )
    Hopefully someone can help me with that problem – would be great!

    (something like) this does not work:

    var source =
    {
        datatype: "json",
        datafields: [
            { name: 'label' },
            { name: 'value' },
            { name: 'group' } // !
        ],
        url: some.php
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    
    $("#jqxdropdownlist").jqxDropDownList({ source: dataAdapter, displayMember: 'label', valueMember: 'value, group:'group'})

    Peter Stoev
    Keymaster

    Hi Robert,

    Actually, that is still not possible and cannot be achieved with the widget.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Robert Jaeger
    Participant

    Well, bad news for me.
    However, thanks for your quick reply!


    Peter Stoev
    Keymaster

    Hi Robert,

    A possible solution came to my mind. if you want to use jqxDataAdapter is to create the jqxDropDownList in the dataAdapter’s loadComplete callback function from the dataAdapter’s records Array, i.e instead of dataAdapter, set the “source” property to point to dataAdapter.records, but do that in the loadComplete callback and also set the dataAdapter’s autoBind setting to true.

    Hope this helps.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    jan
    Participant

    Hello!
    Is it possible to group data by my situation? Im using dropdown list for fitlering jqxgrid column. In column there is multiple similar records, for example names: Ashley, Anna, Elizabeth, Emily, Anna, Rachel, Ashley, Sarah, Sarah, Anna, Elizabeth … 🙂
    My code principle is to bind from jqxgrid records to dropdownlist.
    I need result in dropdownlist like
    Ashley,
    Anna,
    Elizabeth,
    Emily,
    Rachel,
    Sarah.

     $("#names").jqxDropDownList({
            selectedIndex: 0,
            displayMember: "nam",
            valueMember: "name",
            promptText: "",
            incrementalSearch: true,
            incrementalSearchDelay: 400,
            theme: theme,
            width: 100,
            autoDropDownHeight: true
        });
    
    $('#valuta').bind('select', function (event) {
            var args = event.args;
            var item = $('#valuta').jqxDropDownList('getItem', args.index);
            addfilter3(item);
        });
    
     var addfilter3 = function (items) {
            var fnameFilterGroup = new $.jqx.filter();
            var filter_or_operator = 1;
            var filtervalue = items.label;
            var filtercondition = 'EQUAL';
            var fnameFilter1 = fnameFilterGroup.createfilter('stringfilter', filtervalue, filtercondition);
            fnameFilterGroup.addfilter(filter_or_operator, fnameFilter1);
            $("#jqxgrid").jqxGrid('addfilter', 'val', fnameFilterGroup);
            // apply the filters.
            $("#jqxgrid").jqxGrid('applyfilters');
        };

    I tried to make something like http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/customfiltering.htm but without success. Can you post some working code example like my situation?
    Thank You!

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

You must be logged in to reply to this topic.