5

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
codegurl
  • 131
  • 1
  • 3
  • 5

1 Answers1

5

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.

Mario Marinato
  • 4,561
  • 3
  • 29
  • 49
  • I have a different problem. I want to see the up/down arrow pointers. I don't see them for some reason. I do have setSortDirection() in my getSelectionAdapter(). – Kumar S Sep 14 '11 at 20:55