Hi all,
I created a grouped Multi SelectItem which worked and looked fine. However, I want a user to be able to select all /deselect all also in collapsed groups once he/she clicks on the SelectItem grid's header checkbox.
 
My idea is to expand all the groups once the user clicks on the header checkbox and depending the records' selection state I fire either a deselectAll or selectAllRecords on all groups' records.
However I can’t access the select Item’s groups. In the code below I experimented with the picklistProperties ListGrid (since it's the same ListGrid I used to set the SelectItem's groups) in the HeaderClickHandler with getGroupTree().openAll () but it is always null.
Am I missing out something? Please look at my code and provide me with clues on how I can achieve “select all/deselect all" on all records (including collapsed groups) of a grouped multi SelectItem
Thanks
	
							
						
					I created a grouped Multi SelectItem which worked and looked fine. However, I want a user to be able to select all /deselect all also in collapsed groups once he/she clicks on the SelectItem grid's header checkbox.
My idea is to expand all the groups once the user clicks on the header checkbox and depending the records' selection state I fire either a deselectAll or selectAllRecords on all groups' records.
However I can’t access the select Item’s groups. In the code below I experimented with the picklistProperties ListGrid (since it's the same ListGrid I used to set the SelectItem's groups) in the HeaderClickHandler with getGroupTree().openAll () but it is always null.
Am I missing out something? Please look at my code and provide me with clues on how I can achieve “select all/deselect all" on all records (including collapsed groups) of a grouped multi SelectItem
Thanks
Code:
	
	private static FormItem createGroupedSelectItem() {
        final SelectItem item = new SelectItem(); // field left out
        item.setPickListFields(new ListGridField("name"), new ListGridField("type"));
        item.setPickListWidth(400);
        item.setAllowEmptyValue(false);
        item.setMultiple(true);
        item.setDisplayField("name");
        final ListGrid picklistProperties = new ListGrid() {
            {
                setGroupByField("type");
                setShowFilterEditor(true);
                setBackgroundColor("white");
                setSort(new SortSpecifier[] { new SortSpecifier("type", SortDirection.ASCENDING),
                        new SortSpecifier("name", SortDirection.ASCENDING) });
            }
        };
        picklistProperties.addHeaderClickHandler(new HeaderClickHandler() {
            @Override
            public void onHeaderClick(HeaderClickEvent event) {
                if (event.getFieldNum() == 0) {
                    item.getClientPickListData();
                    if (picklistProperties.getSelectedRecord() != null) {
                        picklistProperties.getGroupTree().openAll();
                        picklistProperties.deselectAllRecords();
                    }
                }
            }
        });
        item.setPickListProperties(picklistProperties);
        return item;
    }
Comment