Add grouping to a ComboBoxItem

I’m wanting to implement grouping within a ComboBoxItem. My idea would be that when the pickListIcon is clicked the list would be grouped by a specific column with the groups expanded. I’m able to have the list sorted on that desired column, but would rather have the list grouped into sections by that column.

I’m trying to do this by setting the pickListProperties as follows:

ListGrid pickListProperties = new ListGrid();
pickListProperties.setShowHeader(true);
pickListProperties.setCanGroupBy(true);
pickListProperties.setGroupByField("Account Type");
pickListProperties.setGroupStartOpen(GroupStartOpen.ALL);


ComboBoxItem accounts = new ComboBoxItem();

accounts.setTitle("Accounts");
accounts.setOptionDataSource(accountListDataSource);
accounts.setAutoFetchData(true);

ListGridField accountIdField = new ListGridField("Account Id", "Id");
ListGridField accountNameField = new ListGridField("Account Name", "Name");
ListGridField accountType = new ListGridField("Account Type");

accounts.setPickListProperties(pickListProperties);
accounts.setPickListFields(accountIdField, accountNameField, accountType);
		
accounts.setFilterFields("Account Id", "Account Name");
accounts.setDisplayField("Account Name");

What I would expect is that the options that I set in the pickListProperties would be applied to the pickList but it appears as thought some of the settings are not applied.

Is there a list of which settings are valid for a ComboBoxItem?

Thanks.

Your groupByField is not a valid field name (has a space).

I’ve changed it to be just “AccountType” and not having any better luck. I’ve also noticed that when I right click on the header bar there is a menu option to group by the AccountType but it is grayed out.

Am I correnct in asusming that the name of the ListGridField is the same as the Field Name to pass to the setGroupByField method?

ListGrid pickListProperties = new ListGrid();
pickListProperties.setShowHeader(true);
pickListProperties.setCanGroupBy(true);
pickListProperties.setGroupByField("AccountType");
pickListProperties.setGroupStartOpen(GroupStartOpen.ALL);

...

ListGridField accountType = new ListGridField("AccountType");

EDIT:
Even rearanging the code to be as follows didn’t work

pickListProperties.setGroupByField(accountType.getName());