Question

I am trying to render in SWT the following table with following rows:

name1 | anotherProperty |BUTTON1(EDIT) BUTTON2(REMOVE) BUTTON3(DEACTIVATE)

Using SWT - Tableviewer adding a remove button to a column in the table I was able to render just one button by column.

Is there a way to do this?

Était-ce utile?

La solution

In the same way that you are adding a single button, you can also add multiple buttons but for those buttons you will need an additional container. You can try out something like below:

col.setLabelProvider(new ColumnLabelProvider() {
  @Override
  public void update(ViewerCell cell) {
     TableItem item = (TableItem) cell.getItem();

     Composite buttonPane = new Composite(getTable(), SWT.NONE);
     buttonPane.setLayout(new FillLayout());

     Button button = new Button(buttonPane,SWT.NONE);
     button.setText("Edit");

     button = new Button(buttonPane,SWT.NONE);
     button.setText("Remove");

     button = new Button(buttonPane,SWT.NONE);
     button.setText("Deactivate");

     TableEditor editor = new TableEditor(getTable());
     editor.grabHorizontal  = true;
     editor.grabVertical = true;
     editor.setEditor(buttonPane, item, columnIndex);
     editor.layout();
     }
  });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top