Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding multiple buttons || cells in a cell in GXT 3.0 Grid

Tags:

java

cell

grid

gwt

gxt

I'm using GXT 3.0 and I want to develop a grid table in it. In table, a cell assigned to be have multiple jobs, like save, delete, update. So I need to develop a grid table which has multiple buttons in a cell. To visualize the problem I'm sharing this image : enter image description here

I tried to add just a cell via

ColumnConfig.setCell() 

method, and It's succeeded. But I must add multiple buttons, or cells to handle events. In short form I need multiple Cells inside a Cell.

  • I know there is a method called ColumnConfig.setWidget(), but it didn't helped. It just added toolbar(or any widget element) to top(header part).
  • Remember that I use GXT 3.0

Thanks for any help.

like image 863
Uğurcan Şengit Avatar asked Dec 02 '25 03:12

Uğurcan Şengit


1 Answers

You must use a CompositeCell :

private CompositeCell<ObjectRow> createCompositeCell(){

HasCell<ObjectRow, String> button1 = new HasCell<ObjectRow, String>() {

  public Cell<String> getCell() {
    return new ButtonCell();
  }

  public FieldUpdater<ObjectRow, String> getFieldUpdater() {
    return null;
  }

  public String getValue(ObjectRow object) {
    return "Button 1";
  }};

  HasCell<ObjectRow, String> button2 = new HasCell<ObjectRow,String>(){

    public Cell<String> getCell() {
      return new ButtonCell();
    }

    public FieldUpdater<ObjectRow, String> getFieldUpdater() {
      return null;
    }

    public String getValue(ObjectRow object) {
      return "Button 2";
    }
  };

  List<HasCell<ObjectRow, ?>> cells = new ArrayList<HasCell<ObjectRow, ?>>();
  cells.add(buton1);
  cells.add(button2);

  CompositeCell<ObjectRow> compositeCell = new CompositeCell<ObjectRow>(cells);

  return compositeCell;
}

You can set a different FieldUpdater for handle button click.

like image 51
Patrice De Saint Steban Avatar answered Dec 04 '25 16:12

Patrice De Saint Steban