On Aug 28, 3:15 am, Karl <[EMAIL PROTECTED]> 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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---