문제

I created tableviewer ( jface)

I have one column with icon.The column show icon of edit if there was a change in the item in the table.

Is it possible to do that one column will not move and will be always lock when I scroll the table ( scroll from left to right ). It could be that I have 50 columns and I want that the first column will be always lock that the user could see the icon.

This is the code of the tableViwer

 public class MyGridViewer extends TableViewer {
 public MyGridViewer (Composite parent) {
super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);

final Table table = this.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);

this.setContentProvider(new MyModelProvider());

    }
  }


 @Override
protected void inputChanged(Object input, Object oldInput) {

removeColumn();



    tableCol = new TableViewerColumn(this, SWT.NONE);
    column = tableCol.getColumn();
    column.setText(dataColumnHeader.getName());
    column.setWidth(100);
    column.setResizable(true);
    column.setMoveable(true);
    tableCol.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            DataRow r = (DataRow) element;
            DataCell c = r.getDataCellByName(dataColumnHeader.getName());
            if (c != null && c.getValue() != null) {
                return c.getValue().toString();
            }
            return null;
        }
         @Override
         public Image getImage(Object element) {
               //Add my imgae
         }
    });



 editingSupport = new StringCellEditingSupport(this, dataColumnHeader);
 tableCol.setEditingSupport(editingSupport);
    super.inputChanged(input, oldInput);

}

도움이 되었습니까?

해결책

This can't be done using one table. You could have two table viewers, one for the frozen column and one for the rest. You would have to synchronize the vertical scrolling of the the two tables. There is a snipped with sample code.

Alternatively I believe Eclipse NatTable supports frozen columns.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top