swt table turn off sort arrows in column header

3.6k views Asked by At

I have the following code which allows the columns in my table to sort by ascending or descending order.

protected void setSortColumn(GridPanelColumn gridPanelColumn, TableColumn column) {
    table.setRedraw(false);
    // check if already selected
    if (sortGridPanelColumn != null && sortGridPanelColumn == gridPanelColumn) {
        // toggle sort order
        sortAscending = !sortAscending;
    } else {
        // set new sort column
        sortGridPanelColumn = gridPanelColumn;
        sortAscending = false;
        table.setSortColumn(column);
    }
    // set sort direction
    table.setSortDirection(sortAscending ? SWT.UP : SWT.DOWN);
    // refresh table
    tableViewer.refresh();
    table.setRedraw(true);
}

The only problem is that when the user clicks on the column header to sort, the arrow causes the column name to dot out (ex: Ccy..^ ) instead of (CCy1 Amount). Is there any way to turn off the showing of the arrows? I would rather not have to bother with resizing my grid columns just to accommodate for the arrows so that the dots don't form..

Any ideas on how to do this?

1

There are 1 answers

1
Mario Marinato On

Simple! Just do not do

 table.setSortDirection(sortAscending ? SWT.UP : SWT.DOWN);

When you call this method, you're just telling SWT which image to use. Without it, the sorting still works, but the arrows do not show.