public ColumnModel build() { return new ColumnModel(columns); }
/** * Returns the cell renderer. * * @param colIndex the column index * @return the cell renderer */ public GridCellRenderer<ModelData> getRenderer(int colIndex) { ColumnConfig c = getColumn(colIndex); return c != null ? c.getRenderer() : null; }
private void disableColumnMenus(ColumnModel columnModel) { columnModel.getColumns().forEach(col -> col.setMenuDisabled(true)); }
protected int[] getColumnWidths() { int colCount = cm.getColumnCount(); int[] columnWidths = new int[colCount]; for (int i = 0; i < colCount; i++) { columnWidths[i] = cm.getColumnWidth(i); } return columnWidths; }
protected List<ColumnData> getColumnData() { int colCount = cm.getColumnCount(); List<ColumnData> cs = new ArrayList<ColumnData>(); for (int i = 0; i < colCount; i++) { String name = cm.getDataIndex(i); ColumnData data = new ColumnData(); data.name = name == null ? cm.getColumnId(i) : name; data.renderer = cm.getRenderer(i); data.id = cm.getColumnId(i); data.style = getColumnStyle(i, false); cs.add(data); } return cs; }
@Override protected String renderRows(int startRow, int endRow) { String groupField = getGroupField(); boolean eg = groupField != null; if (!showGroupedColumn) { int colIndex = cm.findColumnIndex(groupField); if (!eg && lastGroupField != null) { mainBody.update(""); cm.setHidden(cm.findColumnIndex(lastGroupField), false); lastGroupField = null; } else if (eg && (lastGroupField == null || lastGroupField == groupField)) { lastGroupField = groupField; cm.setHidden(colIndex, true); } else if (eg && lastGroupField != null && !groupField.equals(lastGroupField)) { mainBody.update(""); int oldIndex = cm.findColumnIndex(lastGroupField); cm.setHidden(oldIndex, false); lastGroupField = groupField; cm.setHidden(colIndex, true); } } return super.renderRows(startRow, endRow); }
columnToHead = new int[cm.getColumnCount()]; for (int i = 0, mark = 0; i < columnToHead.length; i++) { columnToHead[i] = cm.isHidden(i) ? -1 : mark++; table.setWidth(cm.getTotalWidth() + "px"); List<HeaderGroupConfig> configs = cm.getHeaderGroups(); int cols = cm.getColumnCount(); Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < rows - 1; i++) { for (HeaderGroupConfig config : cm.getHeaderGroups()) { int col = config.getColumn(); int row = config.getRow(); for (HeaderGroupConfig config : cm.getHeaderGroups()) { int col = config.getColumn(); int row = config.getRow(); if (rows > 1) { for (int i = col; i < (col + cs); i++) { if (!cm.isHidden(i)) { hide = false; if (cs > 1) { for (int i = col; i < (col + cs); i++) { if (cm.isHidden(i)) { ncs -= 1;
protected void doFocus(int colIndex) { if (isVisible()) { ColumnModel cm = this.grid.getColumnModel(); for (int i = colIndex, len = cm.getColumnCount(); i < len && i >= 0; i++) { ColumnConfig c = cm.getColumn(i); if (!c.isHidden() && c.getEditor() != null) { c.getEditor().getField().focus(); break; } } } }
if (grid.getSelectionModel() instanceof CheckBoxSelectionModel<?>) { CheckBoxSelectionModel<?> sm = (CheckBoxSelectionModel<?>) grid.getSelectionModel(); if (cm.getColumnById(sm.getColumn().getId()) != null) { rowBodyColSpanCount--; for (ColumnConfig c : cm.getColumns()) { if (c instanceof RowExpander || c instanceof RowNumberer) { rowBodyColSpanCount--; String role = "gridcell"; if (GXT.isAriaEnabled()) { ColumnConfig cc = cm.getColumn(i); if (cc.isRowHeader()) { role = "rowheader";
public void handleEvent(GridEvent<RuleModel> be) { Dispatcher.forwardEvent(GeofenceEvents.SEND_INFO_MESSAGE, new String[]{"DEBUG","Resizing " + be.getGrid().getColumnModel().getColumnId(be.getColIndex())}); for (int i = 0; i < be.getGrid().getStore().getCount(); i++) { // there should be only 1 row // let's force a resize on all the columns for (int col = 0; col < be.getGrid().getColumnModel().getColumnCount(); col++) { // final Widget widget = be.getGrid().getView().getWidget(i, be.getColIndex()); final Widget widget = be.getGrid().getView().getWidget(i, col); // Dispatcher.forwardEvent(GeofenceEvents.SEND_INFO_MESSAGE, // new String[]{"DEBUG","Resizing " + widget.getClass().getName() + "--" + widget.getTitle()}); int colWidth = be.getGrid().getColumnModel().getColumn(col).getWidth(); if ((widget != null) && (widget instanceof BoxComponent)) { // ((BoxComponent) widget).setWidth(be.getWidth() - offset); ((BoxComponent) widget).setWidth(colWidth - offset); } } } } }
table.setCellSpacing(0); int cols = cm.getColumnCount(); for (int i = 0; i < cols; i++) { Foot f = new Foot(config, cm.getDataIndex(i)); String cellStyle = config.getCellStyle(cm.getDataIndex(i)); if (cellStyle == null) { cellStyle = ""; "x-grid3-cell x-grid3-footer-cell x-grid3-td-" + cm.getColumnId(i) + " " + cellStyle); HorizontalAlignment align = cm.getColumnAlignment(i); if (cm.isHidden(i)) { updateColumnHidden(i, true);
protected void fitColumns(boolean preventRefresh, boolean onlyExpand, int omitColumn) { int tw = cm.getTotalWidth(false); int aw = grid.el().getWidth(true) - getScrollAdjust(); if (aw <= 0) { int colCount = cm.getColumnCount(); Stack<Integer> cols = new Stack<Integer>(); int width = 0; w = cm.getColumnWidth(i); if (!cm.isHidden(i) && !cm.isFixed(i) && i != omitColumn) { cols.push(i); cols.push(w); int i = cols.pop(); int ww = Math.max(grid.getMinColumnWidth(), (int) Math.floor(w + w * frac)); cm.setColumnWidth(i, ww, true); width = 0; for (int i = 0; i < colCount; i++) { w = cm.getColumnWidth(i); if (!cm.isHidden(i) && !cm.isFixed(i) && w > grid.getMinColumnWidth()) { cols.push(i); cols.push(w); int i = cols.pop(); int ww = Math.max(grid.getMinColumnWidth(), (int) Math.floor(w + w * frac)); cm.setColumnWidth(i, ww, true);
if (cm.isHidden(i)) { continue; String id = head.getElement().getAttribute("x-col"); ColumnConfig cc = cm.getColumnById(id); if (cc == null) return; int w = cc.getWidth(); int mark = group.config.getColumn(); for (int k = mark; k < (mark + colspan); k++) { ColumnConfig c = cm.getColumn(k); if (c.isHidden()) { mark++; continue; w += cm.getColumnWidth(k);
protected void initFields() { ColumnModel cm = grid.getColumnModel(); for (int i = 0, len = cm.getColumnCount(); i < len; i++) { ColumnConfig c = cm.getColumn(i); CellEditor ed = c.getEditor(); Field<?> f = ed != null ? ed.getField() : new LabelField(); if (f instanceof TriggerField<?>) { ((TriggerField<? extends Object>) f).setMonitorTab(true); } f.setWidth(cm.getColumnWidth(i)); HBoxLayoutData ld = new HBoxLayoutData(); if (i == 0) { ld.setMargins(new Margins(0, 1, 2, 1)); } else if (i == len - 1) { ld.setMargins(new Margins(0, 0, 2, 1)); } else { ld.setMargins(new Margins(0, 1, 2, 2)); } f.setMessageTarget("tooltip"); f.addStyleName("x-row-editor-field"); // needed because we remove it from the celleditor clearParent(f); insert(f, i, ld); } initialized = true; }
/** * Returns the column count. * * @return the column count */ public int getColumnCount() { return getColumnCount(false); }
public void addColumOrder(CujoProperty cujo) { int actualPIndex = getColumnModel().findColumnIndex(cujo.getName()); //getCujoModel().getPropertyList().findProperty(cujo.getName()).getIndex(); String h = new String(); for (ColumnConfig columnConfig2 : getColumnModel().getColumns()) { h = h + "--" + columnConfig2.getHeader(); } //change also in cujo model ? CujoProperty[] cpl = getCujoModel().getPropertyList().toArray(new CujoProperty[0]); CujoProperty tmp = cpl[actualPIndex]; cpl[actualPIndex] = cpl[columnOrderSize]; cpl[columnOrderSize] = tmp; //change colum config - swap in list ? List<ColumnConfig> ccl = getColumnModel().getColumns(); ColumnConfig tmpcc1 = ccl.get(actualPIndex); ColumnConfig tmpcc2 = ccl.get(columnOrderSize); ccl.remove(actualPIndex); ccl.remove(columnOrderSize); ccl.add(columnOrderSize, tmpcc1); ccl.add(actualPIndex, tmpcc2); // h = new String(); for (ColumnConfig columnConfig2 : getColumnModel().getColumns()) { h = h + "--" + columnConfig2.getHeader(); } columnOrderSize++; }
int colIndex = cm.findColumnIndex(groupField); String gidPrefix = grid.getId(); ColumnConfig cfg = cm.getColumn(colIndex);
if (grid.getSelectionModel() instanceof CheckBoxSelectionModel<?>) { CheckBoxSelectionModel<?> sm = (CheckBoxSelectionModel<?>) grid.getSelectionModel(); if (cm.getColumnById(sm.getColumn().getId()) != null) { rowBodyColSpanCount--; for (ColumnConfig c : cm.getColumns()) { if (c instanceof RowExpander || c instanceof RowNumberer) { rowBodyColSpanCount--;
protected void verifyLayout(boolean force) { if (initialized && (isVisible() || force)) { Element row = (Element) grid.getView().getRow(rowIndex); setSize(El.fly(row).getWidth(false), renderButtons ? btns.getHeight() : 0); syncSize(); ColumnModel cm = grid.getColumnModel(); for (int i = 0, len = cm.getColumnCount(); i < len; i++) { if (!cm.isHidden(i)) { Field<?> f = (Field<?>) getItem(i); f.show(); f.getElement().setAttribute("gxt-dindex", "" + cm.getDataIndex(i)); MarginData md = (MarginData) ComponentHelper.getLayoutData(f); f.setWidth(cm.getColumnWidth(i) - md.getMargins().left - md.getMargins().right); } else { getItem(i).hide(); } } layout(true); positionButtons(); } }
boolean hasChange = false; ColumnModel cm = grid.getColumnModel(); for (int i = 0, len = cm.getColumnCount(); i < len; i++) { if (!cm.isHidden(i)) { Component c = getItem(i); if (c instanceof LabelField) { String dindex = cm.getDataIndex(i); Object oldValue = record.get(dindex); CellEditor ed = cm.getEditor(i); Object value = ed != null ? ed.postProcessValue(f.getValue()) : f.getValue(); if ((oldValue == null && value != null) || (oldValue != null && !oldValue.equals(value))) {