Class GridColumn

java.lang.Object
com.codename1.ui.table.GridColumn

public class GridColumn extends Object

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);
  • 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.