Title: Groups in combobox Post by: carcaret on May 10, 2013, 03:06:12 AM Hi!
I was trying to accomplish something with combobox but not sure how to do it. Let's say I have a combobox with 12 options, and let's say those options are divided into 3 groups, so 4 options per group. What I'd like to do is prior to the first option of each group, add the name of the group, and make it not selectable, so it'd look like this: Group1 (not selectable) Option11 Option12 Option13 Option14 Group2 (not selectable) Option21 Option22 Option23 Option24 Group3 (not selectable) Option31 Option32 Option33 Option34 I've tried to play with 'onLoadSuccess' event and the 'formatter', but not sure how to do it correctly, any suggestion? Thanks! Title: Re: Groups in combobox Post by: carcaret on May 10, 2013, 05:02:36 AM Forgot to say that I'm retrieving the options via AJAX, and then I wanted to add de group names via javascript. Is that possible?
Title: Re: Groups in combobox Post by: stworthy on May 10, 2013, 08:29:29 AM Here is the example shows how to achieve the group item in combobox.
Code: var data = [ Title: Re: Groups in combobox Post by: carcaret on May 13, 2013, 03:19:00 AM Thanks a lot, worked perfectly.
Title: Re: Groups in combobox Post by: andrux on June 15, 2013, 11:40:05 AM Great, this thread helped me get the group feature working!
I would like to ask something about this, though, how do you add also items with no group? I tried a couple variations including the one below but they don't work, I get a Cannot read property 'value' of undefined error. Code: var data = [ Thanks for any help Title: Re: Groups in combobox Post by: stworthy on June 15, 2013, 06:26:41 PM The group combobox will be supported in version 1.3.4. The updated combobox plugin can be downloaded from http://www.jeasyui.com/easyui/plugins/jquery.combobox.js. Please refer to this example http://www.jeasyui.com/demo/main/index.php?plugin=ComboBox&theme=default&dir=ltr&pitem=Group%20ComboBox or the code below.
Code: <!DOCTYPE html> Title: Re: Groups in combobox Post by: andrux on June 15, 2013, 06:28:01 PM Thanks, I'll give it a try
Title: Re: Groups in combobox Post by: andrux on June 16, 2013, 07:40:08 PM Thank you, stworthy, it worked! All I needed was to use the combobox.js file you suggested!
Title: Re: Groups in combobox Post by: bluesand4 on June 27, 2013, 10:34:47 AM Hi,
Thanks for the example which helped me a lot. I would like to know how I can set the valueField (i.e. what will be displayed in the combobox after the user selects an option) to be a mix of the group name & the item name (e.g. Grp1-item1). Title: Re: Groups in combobox Post by: bluesand4 on July 01, 2013, 10:42:04 PM any help regarding my question?
Title: Re: Groups in combobox Post by: stworthy on July 02, 2013, 12:42:24 AM To use the group combobox, the 'valueField', 'textField' and 'groupField' should be assigned.
Title: Re: Groups in combobox Post by: aswzen on January 13, 2017, 08:58:58 AM How to achieve it thru html ? thank you..
[UPDATE] sorry got it <optgroup label="Swedish Cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> </optgroup> <optgroup label="German Cars"> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </optgroup> |