On Aug 28, 3:15 am, Karl <
ben...@gmail.com> wrote:
> How can i create aoptgroupinside a combobox?
ListBox does not have an optgroup API, so you need to get the select
element from your ListBox and use the DOM API to add the optgroup.
Something like this:
List<String> options = new ArrayList<String>();
//omitted: fill options with the strings you want to see
in the select list
ListBox lb = new ListBox();
SelectElement select = lb.getElement().cast();
OptGroupElement groupElement =
Document.get().createOptGroupElement();
groupElement.setLabel("My group");
for (String option : options) {
OptionElement optElement =
Document.get().createOptionElement();
//setText results in blank options in IE6/7, use
setInnerText
optElement.setInnerText(option.getName());
groupElement.appendChild(optElement);
}
select.appendChild(groupElement);
Hope that helps,
James