Search code examples
javagwtgridcellgxt

How to handle the click on the cell in the GXT 2.2 grid?


I'm looking for the way to handle the cell click. How to do this if I create a new column in grid in this way:

column = new ColumnConfig();
column.setId("remove");
column.setHeader("Remove");
column.setWidth(100);        
configs.add(column);

?


Solution

  • You have to handle cell clicks on the grid to which the ColumnConfig belongs. For example, say you have Grid grid = new Grid(new ColumnModel(column));, then:

    grid.addListener(Events.CellDoubleClick, new Listener<GridEvent>() {
        public void handleEvent(GridEvent be) {
            // be.getColIndex() gets the index of the column clicked on.
            // if you know the index of `column`, you can compare that number to the colIndex
            // if the numbers are equal, do whatever you want to do
            // see docs for GridEvent at 
            // http://dev.sencha.com/deploy/gxt-2.2.5/docs/api/com/extjs/gxt/ui/client/event/GridEvent.html
        }
    });