- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经实现了自定义列排序器,用于对我的表格中的元素。
class FileColumnSorter extends SortableGrid.ColumnSorter { @Override public void onSortColumn(SortableGrid sortableGrid, TableModelHelper.ColumnSortList columnSortList, SortableGrid.ColumnSorterCallback columnSorterCallback) .... }
When I initialize the FixedWidthGrid I do the following:
FixedWidthGrid dataTable = new FixedWidthGrid(rows, cols);dataTable.setSelectionPolicy(SelectionGrid.SelectionPolicy.ONE_ROW);dataTable.setColumnSorter(new FileColumnSorter());
The scrolltable is initialized the following way:
FixedWidthFlexTable headerTable = createHeaderTable();// Calling the lines described aboveFixedWidthGrid fileListGrid = createDataTable(currentDescriptorList.size(), 6);// Combine the components into a ScrollTablescrollTable = new ScrollTable(fileListGrid, headerTable);scrollTable.setSortPolicy(AbstractScrollTable.SortPolicy.SINGLE_CELL);scrollTable.setColumnSortable(0, false);scrollTable.setColumnSortable(1, true);scrollTable.setColumnSortable(2, true);scrollTable.setColumnSortable(3, true);scrollTable.setColumnSortable(4, true);scrollTable.setColumnSortable(5, false);
When I run the application, I get the built in sorting instead of mycustom sorting. I've also tried to do the following:
ColumnSorter sorter = new FileColumnSorter();FixedWidthGrid dataTable = new FixedWidthGrid(rows, cols) { @Override public ColumnSorter getColumnSorter() { return sorter; }};
To ensure that my sorter get used, but I still get the sameexperience.
Update: Added the FileColumnSorter
class FileColumnSorter extends SortableGrid.ColumnSorter
{
@Override
public void onSortColumn(SortableGrid sortableGrid,
TableModelHelper.ColumnSortList columnSortList,
SortableGrid.ColumnSorterCallback columnSorterCallback)
{
final int column = columnSortList.getPrimaryColumn();
final Integer[] originalOrder = new Integer[sortableGrid.getRowCount()];
for (int i = 0; i < originalOrder.length; i++)
{
originalOrder[i] = i;
}
Arrays.sort(originalOrder, new Comparator<Integer>() {
public int compare(Integer first, Integer second)
{
Descriptor firstDesc = share.getCurrentDescriptors().get(first);
Descriptor secondDesc = share.getCurrentDescriptors().get(second);
if (firstDesc.getType().equals(secondDesc.getType()))
{
switch (column)
{
case 0:
return firstDesc.compareTo(secondDesc);
case 1:
return firstDesc.getName().compareTo(secondDesc.getName());
case 2:
return ((Long) firstDesc.getSize()).compareTo(secondDesc.getSize());
case 3:
return firstDesc.getCreated().compareTo(secondDesc.getCreated());
case 4:
return firstDesc.getModified().compareTo(secondDesc.getModified());
default:
return firstDesc.compareTo(secondDesc);
}
}
else
{
return firstDesc.getType() == Descriptor.FileItemType.FOLDER ? 1 : -1;
}
}
});
int[] resultOrder = new int[originalOrder.length];
for (int i = 0; i < originalOrder.length; i++)
{
if (columnSortList.isPrimaryAscending())
{
resultOrder[i] = originalOrder[i];
}
else
{
resultOrder[resultOrder.length - i - 1] = originalOrder[i];
}
}
columnSorterCallback.onSortingComplete(resultOrder);
}
}
最佳答案
我发现了这个关于如何将 PagingScrollTable 与 GWT 孵化器结合使用的很棒的示例。也许您可以使用它而不是实现您自己的:http://zenoconsulting.wikidot.com/blog:17
关于java - 如何使用 ScrollTable 实现自定义 ColumnSorter(GWT 孵化器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1379525/
我正在将 Selenium WebDriver 与 Java 和 ChromeDriver 结合使用。 我想单击下面所示表格中的一个单元格,但由于表格溢出并且有滚动条,因此无法保证该单元格实际上位于
现在我正在玩ScrollTable from GWT Incubator 。我试图在用户选择一行然后单击“编辑”按钮时实现功能,然后他将能够编辑该特定对象。现在我必须检查已选择哪一行 Integer
我已经实现了自定义列排序器,用于对我的表格中的元素。 class FileColumnSorter extends SortableGrid.ColumnSorter {
我是一名优秀的程序员,十分优秀!