Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class GridColumn
- Object
- GridColumn
One column of a DataGrid: which column of the model it shows, its
title and width, and how its values are painted, compared and edited.
A column is a description, not a component. Changing one after it was
added to a grid takes effect on the grid’s next layout; call
DataGrid#refresh() to ask for it.
GridColumn price = new GridColumn(2, "Price")
.setKind(GridColumn.Kind.NUMBER)
.setWidthMM(22)
.setAggregate(GridAggregate.SUM);Nested types
enum GridColumn.Kind | What a column holds, which decides how it is aligned, compared and edited. |
Constructors
public GridColumn(int modelColumn, String title) | A column showing column modelColumn of the model, titled title. |
Methods
public int getModelColumn() | The column of the model this column shows. |
public String getTitle() | The text in the header. |
public GridColumn setTitle(String title) | Sets the text in the header. |
public GridColumn.Kind getKind() | What the column holds. |
public GridColumn setKind(GridColumn.Kind kind) | Sets what the column holds; AUTO by default. |
public float getWidthMM() | The width asked for, in millimetres; 0 sizes the column to its title and the first rows. |
public GridColumn setWidthMM(float widthMM) | Sets the width, in millimetres; 0, the default, sizes the column to what it shows. |
public float getMinWidthMM() | The narrowest a resize may make the column, in millimetres. |
public GridColumn setMinWidthMM(float minWidthMM) | Sets the narrowest a resize may make the column, in millimetres. |
public float getMaxWidthMM() | The widest the column sizes itself to what it shows, in millimetres. |
public GridColumn setMaxWidthMM(float maxWidthMM) | Sets the widest the column sizes itself to what it shows, in millimetres. |
public int getFlex() | The share of the width left over when the columns are narrower than the grid; 0, the default, takes none. |
public GridColumn setFlex(int flex) | Sets the share of the left over width this column takes. |
public int getAlignment() | The alignment of the values: Component.LEFT, CENTER or RIGHT, or -1 to align by kind. |
public GridColumn setAlignment(int alignment) | Sets the alignment of the values; -1, the default, right aligns numbers, centres check boxes and left aligns the rest. |
public int resolveAlignment(Object value) | The alignment a value is painted with, from getAlignment() or the value’s kind. |
public GridColumn.Kind resolveKind(Object value) | The kind of one value: the column’s kind, or the value’s own when the column’s is AUTO. |
public boolean isSortable() | Whether a tap on the header sorts by this column. |
public GridColumn setSortable(boolean sortable) | Sets whether a tap on the header sorts by this column. |
public boolean isResizable() | Whether the edge of the header can be dragged to resize the column. |
public GridColumn setResizable(boolean resizable) | Sets whether the column can be resized by dragging its header edge. |
public boolean isMovable() | Whether the header can be dragged to move the column. |
public GridColumn setMovable(boolean movable) | Sets whether the header can be dragged to move the column. |
public boolean isEditable() | Whether the column’s cells may be edited. |
public GridColumn setEditable(boolean editable) | Sets whether the column’s cells may be edited. |
public boolean isVisible() | Whether the column is shown. |
public GridColumn setVisible(boolean visible) | Shows or hides the column. |
public GridCellRenderer getRenderer() | The renderer of the cells, or null for the grid’s default. |
public GridColumn setRenderer(GridCellRenderer renderer) | Sets the renderer of the cells; null uses the grid’s default. |
public GridCellEditor getEditor() | The editor of the cells, or null for the grid’s default. |
public GridColumn setEditor(GridCellEditor editor) | Sets the editor of the cells; null uses the grid’s default. |
public GridFormatter getFormatter() | How values are turned into text, or null for the default. |
public GridColumn setFormatter(GridFormatter formatter) | Sets how values are turned into text and read back from it. |
public String format(Object value) | The text a value is shown as. |
public Comparator<Object> getComparator() | How two values of the column are ordered, or null for the default order: numbers by value, dates by time, booleans false first, and everything else by its text, ignoring case. |
public GridColumn setComparator(Comparator<Object> comparator) | Sets how two values of the column are ordered. |
public int compare(Object a, Object b) | Compares two values with getComparator() or the default order. |
public GridAggregate getAggregate() | What a group row shows in this column, or null for nothing. |
public GridColumn setAggregate(GridAggregate aggregate) | Sets what a group row shows in this column, such as GridAggregate.SUM. |
public Object[] getChoices() | The values a CHOICE column picks from. |
public GridColumn setChoices(Object... choices) | Sets the values a CHOICE column picks from, and makes it one. |
Inherited methods
Constructor details
GridColumn
public GridColumn(int modelColumn, String title)A column showing column
modelColumn of the model, titled title.Method details
getModelColumn
public int getModelColumn()The column of the model this column shows.
getTitle
public String getTitle()The text in the header.
setTitle
public GridColumn setTitle(String title)Sets the text in the header.
getKind
public GridColumn.Kind getKind()What the column holds.
setKind
public GridColumn setKind(GridColumn.Kind kind)Sets what the column holds;
AUTO by default.getWidthMM
public float getWidthMM()The width asked for, in millimetres; 0 sizes the column to its
title and the first rows.
setWidthMM
public GridColumn setWidthMM(float widthMM)Sets the width, in millimetres; 0, the default, sizes the column to
what it shows.
getMinWidthMM
public float getMinWidthMM()The narrowest a resize may make the column, in millimetres.
setMinWidthMM
public GridColumn setMinWidthMM(float minWidthMM)Sets the narrowest a resize may make the column, in millimetres.
getMaxWidthMM
public float getMaxWidthMM()The widest the column sizes itself to what it shows, in millimetres.
setMaxWidthMM
public GridColumn setMaxWidthMM(float maxWidthMM)Sets the widest the column sizes itself to what it shows, in
millimetres. A resize by the user may go past it.
getFlex
public int getFlex()The share of the width left over when the columns are narrower than
the grid; 0, the default, takes none.
setFlex
public GridColumn setFlex(int flex)Sets the share of the left over width this column takes.
getAlignment
public int getAlignment()The alignment of the values:
Component.LEFT, CENTER or RIGHT,
or -1 to align by kind.setAlignment
public GridColumn setAlignment(int alignment)Sets the alignment of the values; -1, the default, right aligns
numbers, centres check boxes and left aligns the rest.
resolveAlignment
public int resolveAlignment(Object value)The alignment a value is painted with, from
getAlignment() or the
value’s kind.resolveKind
public GridColumn.Kind resolveKind(Object value)The kind of one value: the column’s kind, or the value’s own when the
column’s is
AUTO.isSortable
public boolean isSortable()Whether a tap on the header sorts by this column.
setSortable
public GridColumn setSortable(boolean sortable)Sets whether a tap on the header sorts by this column.
isResizable
public boolean isResizable()Whether the edge of the header can be dragged to resize the column.
setResizable
public GridColumn setResizable(boolean resizable)Sets whether the column can be resized by dragging its header edge.
isMovable
public boolean isMovable()Whether the header can be dragged to move the column.
setMovable
public GridColumn setMovable(boolean movable)Sets whether the header can be dragged to move the column.
isEditable
public boolean isEditable()Whether the column’s cells may be edited. A cell is edited only when
the column and the model both allow it.
setEditable
public GridColumn setEditable(boolean editable)Sets whether the column’s cells may be edited.
isVisible
public boolean isVisible()Whether the column is shown.
setVisible
public GridColumn setVisible(boolean visible)Shows or hides the column. A hidden column keeps its place.
getRenderer
public GridCellRenderer getRenderer()The renderer of the cells, or null for the grid’s default.
setRenderer
public GridColumn setRenderer(GridCellRenderer renderer)Sets the renderer of the cells; null uses the grid’s default.
getEditor
public GridCellEditor getEditor()The editor of the cells, or null for the grid’s default.
setEditor
public GridColumn setEditor(GridCellEditor editor)Sets the editor of the cells; null uses the grid’s default.
getFormatter
public GridFormatter getFormatter()How values are turned into text, or null for the default.
setFormatter
public GridColumn setFormatter(GridFormatter formatter)Sets how values are turned into text and read back from it.
format
public String format(Object value)The text a value is shown as.
getComparator
public Comparator<Object> getComparator()How two values of the column are ordered, or null for the default
order: numbers by value, dates by time, booleans false first, and
everything else by its text, ignoring case.
setComparator
public GridColumn setComparator(Comparator<Object> comparator)Sets how two values of the column are ordered. It is never given a
null: nulls sort first.
compare
public int compare(Object a, Object b)Compares two values with
getComparator() or the default order.
Null comes first.getAggregate
public GridAggregate getAggregate()What a group row shows in this column, or null for nothing.
setAggregate
public GridColumn setAggregate(GridAggregate aggregate)Sets what a group row shows in this column, such as
GridAggregate.SUM.getChoices
public Object[] getChoices()The values a
CHOICE column picks from.setChoices
public GridColumn setChoices(Object... choices)Sets the values a
CHOICE column picks from, and makes it one.