Class ColumnSelector<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.html.Div>
org.vaadin.addons.antlerflow.grid.columns.ColumnSelector<T>
Type Parameters:
T - the type of items in the grid
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

public class ColumnSelector<T> extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.html.Div>
Lets the user choose which columns of a grid are displayed. At least one column always stays visible. Every change made by the user is reported to the change listener as the complete column id to visibility map, ready to be persisted.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ColumnSelector(com.vaadin.flow.component.grid.Grid<T> grid, com.vaadin.flow.function.SerializableConsumer<Map<String,Boolean>> changeListener)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Applies a stored preference.
    Returns the current column id to visibility map, in column order.
    void
    Re-reads the grid's columns; call it after columns are added or removed.
    void
    Restores the default visibility and reports it to the change listener.
    void
    setGrid(com.vaadin.flow.component.grid.Grid<T> grid)
    Switches the selector to another grid and forgets the previous grid's defaults.

    Methods inherited from class com.vaadin.flow.component.Composite

    getChildren, getContent, getElement, initContent

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • ColumnSelector

      public ColumnSelector(com.vaadin.flow.component.grid.Grid<T> grid, com.vaadin.flow.function.SerializableConsumer<Map<String,Boolean>> changeListener)
  • Method Details

    • setGrid

      public void setGrid(com.vaadin.flow.component.grid.Grid<T> grid)
      Switches the selector to another grid and forgets the previous grid's defaults.
    • refresh

      public void refresh()
      Re-reads the grid's columns; call it after columns are added or removed.
    • applyPreference

      public void applyPreference(Map<String,Boolean> visibility)
      Applies a stored preference. Unknown ids are ignored and columns missing from the preference keep their default visibility. If the preference would hide every column, it is not applied.
    • getVisibility

      public Map<String,Boolean> getVisibility()
      Returns the current column id to visibility map, in column order.
    • reset

      public void reset()
      Restores the default visibility and reports it to the change listener.