Search code examples
gwtgxt

GXT: Filter Grid add select all columns checkbox


I have a Filter Grid component similar to the icon below. What I want is to add a Select All functionality in the columns section of the header. I've done my research but I can't find any kind of solution. Not even a direction. I want to be able to attach a handler to that checkbox that will check/uncheck all of the below options.

The module in question

I'm using Sencha GXT 3.1.0 and and GWT 2.6.1

The icon enter image description here


Solution

  • Here's how to do this , override createContextMenu of the GridView

    ColumnModel<HashMap> cm = new ColumnModel<HashMap>(l);
    
    GridView<HashMap> gridView = new GridView<HashMap>()
    {
        @Override
        protected void initHeader()
        {
            super.initHeader();
        }
    
        protected Menu createContextMenu(final int colIndex)
        {
            Menu createContextMenu = super.createContextMenu(colIndex);
    
            final CheckMenuItem check = new CheckMenuItem();
            check.setHideOnClick(false);
            check.setHTML("Toggle Selection");
            check.setChecked(true);
    
            check.addCheckChangeHandler(new CheckChangeHandler<CheckMenuItem>()
            {
    
                @Override
                public void onCheckChange(CheckChangeEvent<CheckMenuItem> event)
                {
                    Window.alert("Toggle Selection");
                }
            });
    
            createContextMenu.add(check);
    
            return createContextMenu;
    
        }
    
    };
    
    Grid grid = new Grid(store, cm, gridView);