public ColumnModel<Integer> buildColumnModel() { ColumnModel<Integer> cm = new ColumnModel<>(columnConfigs); for (HeaderGroupConfig headerGroupConfig : headerGroupConfigs) { cm.addHeaderGroup(headerGroupConfig.getRow(), headerGroupConfig.getColumn(), headerGroupConfig); } return cm; }
ColumnConfig columnConfig = SenchaGridUtils.createDefaultColumnConfig(valueProvider, actionsColumnWidth, MessagesFactory.bo().actions(), buttonsCell); columnConfig.setFixed(true); return columnConfig;
@Override public View getView(int position, View convertView, ViewGroup parent) { GridView grid = (GridView)parent; int size = grid.getColumnWidth(); if (convertView == null){ convertView = LayoutInflater.from(context).inflate(R.layout.your_item, null); convertView.setLayoutParams(new GridView.LayoutParams(size, size)); } //Modify your convertView here return convertView; }
private ColumnModel<Point> buildColumnModel(DimensionSet dimensionSet) { List<ColumnConfig<Point, ?>> columns = new ArrayList<>(); for (int i = 0; i < dimensionSet.getCount(); i++) { ColumnConfig<Point, String> column = new ColumnConfig<>(new PointDimProvider(i)); column.setHeader(dimensionSet.getDimension(i).getLabel()); column.setSortable(false); column.setHideable(false); columns.add(column); } ColumnConfig<Point, Double> valueColumn = new ColumnConfig<>(new PointValueProvider()); valueColumn.setHeader(I18N.CONSTANTS.value()); valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END); valueColumn.setSortable(false); valueColumn.setHideable(false); columns.add(valueColumn); return new ColumnModel<>(columns); }
private void addGeoPointColumn(EffectiveTableColumn columnModel, GeoPointFormat format) { // Add a single, comma-delimited list for now ValueProvider<Integer, Double> latProvider = proxy.getValueProvider(format.getLatitudeId(), format.createLatitudeRenderer()); ValueProvider<Integer, Double> lngProvider = proxy.getValueProvider(format.getLongitudeId(), format.createLongitudeRenderer()); int latitudeColumnIndex = columnConfigs.size(); ColumnConfig<Integer, Double> latitudeConfig = new ColumnConfig<>(latProvider); latitudeConfig.setHeader(I18N.CONSTANTS.latitude()); latitudeConfig.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); columnConfigs.add(latitudeConfig); ColumnConfig<Integer, Double> longitudeConfig = new ColumnConfig<>(lngProvider); longitudeConfig.setHeader(I18N.CONSTANTS.longitude()); longitudeConfig.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); columnConfigs.add(longitudeConfig); HeaderGroupConfig groupConfig = new HeaderGroupConfig(SafeHtmlUtils.fromString(columnModel.getLabel()), 1, 2); groupConfig.setRow(0); groupConfig.setColumn(latitudeColumnIndex); headerGroupConfigs.add(groupConfig); }
public void maybeUpdateSortingView(List<SortModel> sorting) { if(!currentSorting.equals(sorting)) { ColumnModel<Integer> columnModel = grid.getColumnModel(); ColumnHeader<Integer> tableHeading = grid.getView().getHeader(); if (sorting.isEmpty()) { tableHeading.updateSortIcon(-1, SortDir.ASC); } else { SortModel sortModel = sorting.get(0); for (int i = 0; i < columnModel.getColumnCount(); i++) { String path = columnModel.getValueProvider(i).getPath(); if (path.equals(sortModel.getField())) { tableHeading.updateSortIcon(i, sortModel.getDir() == org.activityinfo.model.query.SortDir.ASC ? SortDir.ASC : SortDir.DESC); break; } } } currentSorting = sorting; } }
private void addTextColumn(EffectiveTableColumn tableColumn, TextFormat textFormat) { ValueProvider<Integer, String> valueProvider = proxy.getValueProvider(textFormat); ColumnConfig<Integer, String> config = new ColumnConfig<>(valueProvider, tableColumn.getWidth()); config.setHeader(tableColumn.getLabel()); columnConfigs.add(config); StringFilter<Integer> filter = new StringFilter<>(valueProvider); filters.add(new ColumnView(tableColumn.getFormula(), filter)); }
private void addEnumType(EffectiveTableColumn tableColumn, SingleEnumFormat format) { ValueProvider<Integer, String> valueProvider = proxy.getValueProvider(format); ColumnConfig<Integer, String> config = new ColumnConfig<>(valueProvider, tableColumn.getWidth()); config.setHeader(tableColumn.getLabel()); columnConfigs.add(config); addEnumFilter(valueProvider.getPath(), tableColumn, (EnumType) tableColumn.getType()); }
/** * Creates a context menu for the given column, including sort menu items and column visibility sub-menu. * * @param colIndex the column index * @return the context menu for the given column */ protected Menu createContextMenu(final int colIndex) { final Menu menu = new Menu(); if (cm.isSortable(colIndex)) { MenuItem item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortAscText()); item.setIcon(header.getAppearance().sortAscendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.ASC)); menu.add(item); item = new MenuItem(); item.setText(DefaultMessages.getMessages().gridView_sortDescText()); item.setIcon(header.getAppearance().sortDescendingIcon()); item.addSelectionHandler(event -> doSort(colIndex, SortDir.DESC)); menu.add(item); item = new MenuItem(); item.setText(I18N.CONSTANTS.clearSort()); item.addSelectionHandler(event -> fireEvent(new SortChangeEvent())); menu.add(item); } return menu; }
private int getColumnWidth(Context context, GridView gridView) { if (android.os.Build.VERSION.SDK_INT >= 16) return gridView.getColumnWidth(); Resources res = context.getResources(); int lPad = (int)res.getDimension(R.dimen.left_padding); int rPad = (int)res.getDimension(R.dimen.right_padding); int hSpace = (int)res.getDimension(R.dimen.horizontal_spacing); int cols = gridView.getNumColumns(); int width = gridView.getWidth(); return (width - lPad - rPad + hSpace) / cols - hSpace; }
private void changeColumnWidth(ColumnResizeEvent e) { ColumnConfig<Integer, Object> column = grid.getColumnModel().getColumn(e.getColumnIndex()); LOGGER.info("Column " + column.getValueProvider().getPath() + " resized to " + e.getColumnWidth() + "px"); tableUpdater.updateColumnWidth(column.getValueProvider().getPath(), e.getColumnWidth()); }
public RawTableView(AnalysisViewModel model) { this.model = model; this.store = new ListStore<>(point -> point.toString()); this.grid = new Grid<>(store, buildColumnModel(new DimensionSet())); this.grid.getView().setSortingEnabled(false); this.panel = new ContentPanel(); this.panel.setHeading("Results"); this.panel.add(grid); model.getResultTable().subscribe(observable -> { if (observable.isLoaded()) { update(observable.get()); } else { store.clear(); } }); }
lastTransCol.setCell(new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy")));
@Override protected void initHeader() { if (header == null) { header = new CustomColumnHeader<Integer>(grid, cm); } header.setMenuFactory(new ColumnHeader.HeaderContextMenuFactory() { @Override public Menu getMenuForColumn(int columnIndex) { return createContextMenu(columnIndex); } }); header.setSplitterWidth(splitterWidth); } }
private int addHeaderGroups(ColumnModel<PivotRow> cm, PivotTable.Node parent, int row, int col) { int leafCount = parent.getLeaves().size(); // Add one group for the name of this Dimension cm.addHeaderGroup(row, col, new HeaderGroupConfig(parent.getDimension().getLabel(), 1, leafCount)); for (PivotTable.Node child : parent.getChildren()) { if (child.isLeaf()) { col++; } else { cm.addHeaderGroup(row + 1, col, new HeaderGroupConfig(child.getCategoryLabel(), 1, child.getLeaves().size())); col = addHeaderGroups(cm, child, row + 2, col); } } return col; }
@Override protected void doSort(int colIndex, SortDir sortDir) { String field = grid.getColumnModel().getValueProvider(colIndex).getPath(); org.activityinfo.model.query.SortDir dir; // sortDir is null if the column header is clicked to // toggle the sort direction if(sortDir == null) { if(isFieldSortedAscending(field)) { dir = org.activityinfo.model.query.SortDir.DESC; } else { dir = org.activityinfo.model.query.SortDir.ASC; } } else if(sortDir == SortDir.ASC) { dir = org.activityinfo.model.query.SortDir.ASC; } else { dir = org.activityinfo.model.query.SortDir.DESC; } fireEvent(new SortChangeEvent(field, dir)); }
private void update(PivotTable pivotTable) { grid.reconfigure(store, buildColumnModel(pivotTable)); store.replaceAll(buildRows(pivotTable)); }
@Override protected void onDetach() { super.onDetach(); subscription.unsubscribe(); } };
@Override protected void onAttach() { super.onAttach(); subscription = columnSet.subscribe(observable -> updateColumnView(observable)); loader.load(0, gridView.getCacheSize()); }
private void update(AnalysisResult analysisResult) { grid.reconfigure(store, buildColumnModel(analysisResult.getDimensionSet())); store.replaceAll(analysisResult.getPoints()); }