if you are talking about an optgroup (http://www.w3schools.com/tags/
tryit.asp?filename=tryhtml_optgroup)
I've made myself an new object that extends the default ListBox and
used instead here is the code:
import java.util.HashMap;
import java.util.Map;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.OptGroupElement;
import com.google.gwt.dom.client.OptionElement;
import com.google.gwt.dom.client.SelectElement;
import com.google.gwt.user.client.ui.ListBox;
/**
* @author Lohmar ASHAR
*/
public class ExtendedListBox extends ListBox {
private Map<String, OptGroupElement> groups = new HashMap<String,
OptGroupElement>();
public ExtendedListBox() {
this(false);
}
public ExtendedListBox(boolean isMultipleSelect) {
super(isMultipleSelect);
}
public ExtendedListBox(Element element) {
super(element);
}
public void insertItemToOptGroup(String group, String item, String
value) {
OptGroupElement oge = getGroup(group);
OptionElement option = Document.get().createOptionElement();
option.setText(item);
option.setValue(value);
oge.appendChild(option);
}
private OptGroupElement getGroup(String group) {
OptGroupElement oge = groups.get(group);
if (oge == null) {
insertOptGroup(group);
return getGroup(group);
} else
return oge;
}
public void insertOptGroup(String item) {
SelectElement select = getSelectElement();
OptGroupElement oge = Document.get().createOptGroupElement();
groups.put(item, oge);
oge.setLabel(item);
select.appendChild(oge);
}
private SelectElement getSelectElement() {
return getElement().cast();
}
public String getValue(int index) {
return getOptionValue(this.getElement(), index);
}
public native String getOptionValue(Element elem, int index) /*-{
return elem.options[index].value;
}-*/;
@Override
public void clear() {
groups.clear();
super.clear();
getSelectElement().setInnerHTML("");
}
}
not very fancy, but it suited my needs. hope it helps
good luck
On Jan 11, 5:20 pm, rmuller <[email protected]> wrote:
> Using the standard GWT API this is not possible. Is there a hack
> available?
>
> Ronald
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.