5

我有以下代码,它允许我的表中的列按升序或降序排序。

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);
}

唯一的问题是,当用户单击列标题进行排序时,箭头会导致列名点出来(例如:Ccy..^)而不是(CCy1 Amount)。有没有办法关闭箭头的显示?我宁愿不必费心调整我的网格列的大小来适应箭头,这样点就不会形成..

关于如何做到这一点的任何想法?

4

1 回答 1

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.

于 2011-02-08T16:43:06.743 回答