jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList Dropdown with optgroup from JSON data

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Klaus H 8 years, 11 months ago.

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

  • Klaus H
    Participant

    Hi,

    I’m looking for a way to get a dropdownlist with groups like in this example:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdropdownlist/index.htm#demos/jqxdropdownlist/dropdownlist-from-select.htm

    You transform an existing select tag into the dropdownlist. I would prefer to do this from JSON data. But there is no example for this and the API does not suggest such a behaviour. The only thing I found was the group parameter in the addItem function. But using that parameter does not seem to change anything.

    Is it possible via JSON? If not, might I suggest that for a future version? Maybe with two properties: grouping as boolean and groupMember as String?

    Kind Regards
    Klaus


    Peter Stoev
    Keymaster

    Hi Klaus,

    You can implement grouping with this approach: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdropdownlist/categories.htm?light

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Klaus H
    Participant

    Hi Peter,

    thank you, that works, so basically having a property named group seems to do the trick. I don’t know why it did not work in my example with addItem:

    $("#jqxWidget").jqxDropDownList('addItem', { label: '11', value: '11', group: "1"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '12', value: '12', group: "1"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '13', value: '13', group: "1"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '14', value: '14', group: "1"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '15', value: '15', group: "1"} ); 
    
    $("#jqxWidget").jqxDropDownList('addItem', { label: '21', value: '21', group: "2"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '22', value: '22', group: "2"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '23', value: '23', group: "2"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '24', value: '24', group: "2"} ); 
    $("#jqxWidget").jqxDropDownList('addItem', { label: '25', value: '25', group: "2"} ); 
    

    But this is even better!

    Best Regards
    Klaus

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

You must be logged in to reply to this topic.