public void onColumnSort(ColumnSortEvent event) { // Get the sorted column. Column<?, ?> column = event.getColumn(); if (column == null) { return; } // Get the comparator. final Comparator<T> comparator = comparators.get(column); if (comparator == null) { return; } // Sort using the comparator. if (event.isSortAscending()) { Collections.sort(list, comparator); } else { Collections.sort(list, new Comparator<T>() { public int compare(T o1, T o2) { return -comparator.compare(o1, o2); } }); } }
/** * Add a handler to handle {@link ColumnSortEvent}s. * * @param handler the {@link ColumnSortEvent.Handler} to add * @return a {@link HandlerRegistration} to remove the handler */ public HandlerRegistration addColumnSortHandler(ColumnSortEvent.Handler handler) { return addHandler(handler, ColumnSortEvent.getType()); }
/** * Fires a column sort event on all registered handlers in the handler * manager. If no such handlers exist, this implementation will do nothing. * * @param source the source of the event * @param sortList the {@link ColumnSortList} of sorted columns * @return the {@link ColumnSortEvent} that was fired */ public static ColumnSortEvent fire(HasHandlers source, ColumnSortList sortList) { ColumnSortEvent event = new ColumnSortEvent(sortList); if (TYPE != null) { source.fireEvent(event); } return event; }
private void applySort(ColumnSortEvent event, SortedListModel<T> sortedModel) { Column<?, ?> column = event.getColumn(); if (!(column instanceof SortableColumn)) { sortedModel.setComparator(realComparator, event.isSortAscending()); sortApplied = true; } else if (supportsServerSideSorting) { searchableModel.updateSortOptions(sortableColumn.getSortBy(), event.isSortAscending()); sortApplied = true; } else { sortedModel.setComparator(realComparator, event.isSortAscending()); sortApplied = true; ColumnSortInfo columnSortInfo = event.getColumnSortList().get(0); if (sortApplied) { pushColumnSort(columnSortInfo);
/** * @param data the data. */ public void setData(List<T> data) { _dataProvider.getList().clear(); if (data != null) { _dataProvider.getList().addAll(data); ColumnSortEvent.fire(_table, _table.getColumnSortList()); } }
NameColumn.setSortable(true); patientsTable.addColumnSortHandler(new ColumnSortEvent.Handler() { @Override public void onColumnSort(ColumnSortEvent event) { final Column a = event.getColumn(); List<PatientDTO> newData = new ArrayList(patientsTable.getVisibleItems()); Collections.sort(newData, new Comparator<PatientDTO>() { public int compare(PatientDTO o1, PatientDTO o2) { // code here to sort asc or desc order } }); Range range = patientsTable.getVisibleRange(); int start = range.getStart(); patientsTable.setRowData(start, newData); } });
sortList.push(column); updatingSortList = false; ColumnSortEvent.fire(this, sortList);
tableA.addColumnSortHandler(new ColumnSortEvent.Handler() { @Override public void onColumnSort(ColumnSortEvent event) { Column<MyObject, String> columnA = event.getColumn(); // find columnB in tableB that corresponds to columnA in tableA tableB.getColumnSortList().push(new ColumnSortInfo(columnB, event.isSortAscending())); ColumnSortEvent.fire(tableB, tableB.getColumnSortList()); } });
/** * Add a handler to handle {@link ColumnSortEvent}s. * * @param handler the {@link ColumnSortEvent.Handler} to add * @return a {@link HandlerRegistration} to remove the handler */ public HandlerRegistration addColumnSortHandler(ColumnSortEvent.Handler handler) { return addHandler(handler, ColumnSortEvent.getType()); }
/** * Click on a specific header of a cell table. * * @param table The targeted cell table * @param index The targeted cell header index in the table */ public static void clickHeader(AbstractCellTable<?> table, int index) { BrowserSimulatorImpl.get().fireLoopEnd(); table.getColumnSortList().push(table.getColumn(index)); ColumnSortEvent.fire(table, table.getColumnSortList()); BrowserSimulatorImpl.get().fireLoopEnd(); }
/** * Fires a column sort event on all registered handlers in the handler * manager. If no such handlers exist, this implementation will do nothing. * * @param source the source of the event * @param sortList the {@link ColumnSortList} of sorted columns * @return the {@link ColumnSortEvent} that was fired */ public static ColumnSortEvent fire(HasHandlers source, ColumnSortList sortList) { ColumnSortEvent event = new ColumnSortEvent(sortList); if (TYPE != null) { source.fireEvent(event); } return event; }
public void onColumnSort(ColumnSortEvent event) { // Get the sorted column. Column<?, ?> column = event.getColumn(); if (column == null) { return; } // Get the comparator. final Comparator<T> comparator = comparators.get(column); if (comparator == null) { return; } // Sort using the comparator. if (event.isSortAscending()) { Collections.sort(list, comparator); } else { Collections.sort(list, new Comparator<T>() { public int compare(T o1, T o2) { return -comparator.compare(o1, o2); } }); } }
/** * Add a handler to handle {@link ColumnSortEvent}s. * * @param handler the {@link ColumnSortEvent.Handler} to add * @return a {@link HandlerRegistration} to remove the handler */ public HandlerRegistration addColumnSortHandler(ColumnSortEvent.Handler handler) { return addHandler(handler, ColumnSortEvent.getType()); }
/** * Click on a specific header of a cell table. * * @param table The targeted cell table * @param index The targeted cell header index in the table */ public static void clickHeader(AbstractCellTable<?> table, int index) { BrowserSimulatorImpl.get().fireLoopEnd(); table.getColumnSortList().push(table.getColumn(index)); ColumnSortEvent.fire(table, table.getColumnSortList()); BrowserSimulatorImpl.get().fireLoopEnd(); }
/** * Fires a column sort event on all registered handlers in the handler * manager. If no such handlers exist, this implementation will do nothing. * * @param source the source of the event * @param sortList the {@link ColumnSortList} of sorted columns * @return the {@link ColumnSortEvent} that was fired */ public static ColumnSortEvent fire(HasHandlers source, ColumnSortList sortList) { ColumnSortEvent event = new ColumnSortEvent(sortList); if (TYPE != null) { source.fireEvent(event); } return event; }
public void onColumnSort(ColumnSortEvent event) { // Get the sorted column. Column<?, ?> column = event.getColumn(); if (column == null) { return; } // Get the comparator. final Comparator<T> comparator = comparators.get(column); if (comparator == null) { return; } // Sort using the comparator. if (event.isSortAscending()) { Collections.sort(list, comparator); } else { Collections.sort(list, new Comparator<T>() { public int compare(T o1, T o2) { return -comparator.compare(o1, o2); } }); } }
@Override public HandlerRegistration addColumnSortHandler(ColumnSortEvent.Handler handler) { return handlers.addHandler(ColumnSortEvent.getType(), handler); }
sortList.push(column); updatingSortList = false; ColumnSortEvent.fire(this, sortList);
public void onColumnSort( ColumnSortEvent event ) { lastOrderedColumn = ((DataColumnCell) event.getColumn().getCell()).columnId; lastSortOrder = event.isSortAscending() ? SortOrder.ASCENDING : SortOrder.DESCENDING; redraw(); } });
public static Observable<ColumnSortEvent> columnSort(Widget source) { return Observable.create(s -> register(s, source.addHandler(s::onNext, ColumnSortEvent.getType())), uiBackpressureMode()); }