如何在nat表中排序后将选择放在第一行,我使用SortHeaderLayer进行排序.....提前感谢
SortHeaderLayer<Mapping> sortHeaderLayer =new SortHeaderLayer<Mapping>(columnHeaderLayer, new GlazedListsSortModel<Mapping>(sortedList,columnAccessor,configRegistry, columnHeaderDataLayer), false);
由于
答案 0 :(得分:0)
这可以通过注册ILayerListener
来完成。唯一要记住的是SortColumnEvent
首先被激活,然后GlazedListsEventLayer
触发RowStructuralRefreshEvent
以触发重新绘制。这将在不使用RowSelectionModel
时删除选择。因此,听众需要以反应的方式进行设计。
// an ILayerListener that performs a selection after a refresh and
// unregisters itself afterwards
ILayerListener sortListener = new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof RowStructuralRefreshEvent) {
natTable.doCommand(new SelectRowsCommand(natTable,
1, 1, false, false));
natTable.removeLayerListener(this);
}
}
};
// register an ILayerListener that registers the above listener
// on a SortColumnEvent
natTable.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof SortColumnEvent) {
natTable.addLayerListener(sortListener);
}
}
});