Class PivotTableModel

java.lang.Object
io.jmix.pivottable.model.AbstractPivotObject
io.jmix.pivottable.model.PivotTableModel
All Implemented Interfaces:
Serializable

public class PivotTableModel extends AbstractPivotObject
Description of PivotTable configuration.
https://github.com/nicolaskruchten/pivottable/
See documentation for properties of Pivot() and PivotUI() functions.
https://github.com/nicolaskruchten/pivottable/wiki/Parameters
See Also:
  • Constructor Details

    • PivotTableModel

      public PivotTableModel()
  • Method Details

    • getEditable

      public boolean getEditable()
      Returns:
      if false then pivot() function will be called to generate PivotTable, pivotUI() otherwise
    • setEditable

      public PivotTableModel setEditable(boolean editable)
      Parameters:
      editable - if false then pivot() function will be called to generate PivotTable, pivotUI() otherwise
      Returns:
      a reference to this object
    • getProperties

      public Map<String,String> getProperties()
      Returns:
      data provider properties to serialize
    • setProperties

      public PivotTableModel setProperties(Map<String,String> properties)
      Sets data provider properties to serialize.
      Parameters:
      properties - data provider properties to serialize
      Returns:
      a reference to this object
    • addProperties

      public PivotTableModel addProperties(Map<String,String> properties)
      Adds data provider properties to serialize.
      Parameters:
      properties - data provider properties to serialize
      Returns:
      a reference to this object
    • addProperty

      public PivotTableModel addProperty(String property, String value)
      Sets data provider property to serialize.
      Parameters:
      property - data provider property to serialize
      value - a property value
      Returns:
      a reference to this object
    • getRows

      public List<String> getRows()
      Returns:
      a collection of attribute names to use as rows
    • setRows

      public PivotTableModel setRows(List<String> rows)
      Sets a collection of attribute names to use as rows.
      Parameters:
      rows - a collection of attribute names to use as rows
      Returns:
      a reference to this object
    • addRows

      public PivotTableModel addRows(String... rows)
      Adds an array of attribute names to use as rows.
      Parameters:
      rows - an array of attribute names to add
      Returns:
      a reference to this object
    • getCols

      public List<String> getCols()
      Returns:
      a collection of attribute names to use as columns
    • setCols

      public PivotTableModel setCols(List<String> cols)
      Sets a collection of attribute names to use as columns.
      Parameters:
      cols - a collection of attribute names to use as columns
      Returns:
      a reference to this object
    • addCols

      public PivotTableModel addCols(String... cols)
      Adds an array of attribute names to use as columns.
      Parameters:
      cols - an array of attribute names to add
      Returns:
      a reference to this object
    • getAggregation

      public Aggregation getAggregation()
      Returns:
      an object which will aggregate results per cell
    • setAggregation

      public PivotTableModel setAggregation(Aggregation aggregation)
      Original property name: aggregator.

      Sets a descriptor of an object which will aggregate results per cell (see documentation).

      Applies only when editable=false.

      Parameters:
      aggregation - an object which will aggregate results per cell
      Returns:
      a reference to this object
    • getRenderer

      public Renderer getRenderer()
      Returns:
      an object which will generate output from pivot data structure
    • setRenderer

      public PivotTableModel setRenderer(Renderer renderer)
      Sets a descriptor of an object which will generate output from pivot data structure (see documentation).

      Applies only when editable=false.

      Parameters:
      renderer - an object which will generate output from pivot data structure
      Returns:
      a reference to this object
    • getAggregationProperties

      public List<String> getAggregationProperties()
      Returns:
      attribute names to prepopulate in vals area
    • setAggregationProperties

      public PivotTableModel setAggregationProperties(List<String> aggregationProperties)
      Original property name: vals.

      Sets attribute names to prepopulate in vals area (gets passed to aggregator generating function).

      Applies only when editable=true.

      Parameters:
      aggregationProperties - attribute names to prepopulate in vals area
      Returns:
      a reference to this object
    • addAggregationProperties

      public PivotTableModel addAggregationProperties(String... aggregationProperties)
      Original property name: vals.

      Adds attribute names to prepopulate in vals area (gets passed to aggregator generating function).

      Applies only when editable=true.

      Parameters:
      aggregationProperties - attribute names to prepopulate in vals area
      Returns:
      a reference to this object
    • getAggregations

      public Aggregations getAggregations()
      Returns:
      an object that represents a list of generators for aggregation functions in dropdown
    • setAggregations

      public PivotTableModel setAggregations(Aggregations aggregations)
      Original property name: aggregators.

      Sets an object that represents a list of generators for aggregation functions in dropdown (see documentation).

      Applies only when editable=true.

      Parameters:
      aggregations - an object that represents a list of generators for aggregation functions in dropdown
      Returns:
      a reference to this object
    • getRenderers

      public Renderers getRenderers()
      Returns:
      n object that represents a list of rendering functions
    • setRenderers

      public PivotTableModel setRenderers(Renderers renderers)
      Sets an object that represents a list of rendering functions (see documentation).

      Applies only when editable=true.

      Parameters:
      renderers - n object that represents a list of rendering functions
      Returns:
      a reference to this object
    • getHiddenProperties

      public List<String> getHiddenProperties()
      Returns:
      attribute names to omit from the UI
    • setHiddenProperties

      public PivotTableModel setHiddenProperties(List<String> hiddenProperties)
      Sets attribute names to omit from the UI.

      Applies only when editable=true.

      Parameters:
      hiddenProperties - attribute names to omit from the UI
      Returns:
      a reference to this object
    • addHiddenProperties

      public PivotTableModel addHiddenProperties(String... hiddenProperties)
      Adds attribute names to omit from the UI.

      Applies only when editable=true.

      Parameters:
      hiddenProperties - attribute names to omit from the UI
      Returns:
      a reference to this object
    • getHiddenFromAggregations

      public List<String> getHiddenFromAggregations()
      Returns:
      attribute names to omit from the aggregation arguments dropdowns
    • setHiddenFromAggregations

      public PivotTableModel setHiddenFromAggregations(List<String> hiddenFromAggregations)
      Sets attribute names to omit from the aggregation arguments dropdowns.

      Applies only when editable=true.

      Parameters:
      hiddenFromAggregations - attribute names to omit from the aggregation arguments dropdowns
      Returns:
      a reference to this object
    • addHiddenFromAggregations

      public PivotTableModel addHiddenFromAggregations(String... hiddenFromAggregations)
      Adds attribute names to omit from the aggregation arguments dropdowns.

      Applies only when editable=true.

      Parameters:
      hiddenFromAggregations - attribute names to omit from the aggregation arguments dropdowns
      Returns:
      a reference to this object
    • getHiddenFromDragDrop

      public List<String> getHiddenFromDragDrop()
      Returns:
      attribute names to omit from the drag'n'drop portion of the UI
    • setHiddenFromDragDrop

      public PivotTableModel setHiddenFromDragDrop(List<String> hiddenFromDragDrop)
      Sets attribute names to omit from the drag'n'drop portion of the UI.

      Applies only when editable=true.

      Parameters:
      hiddenFromDragDrop - attribute names to omit from the drag'n'drop portion of the UI
      Returns:
      a reference to this object
    • addHiddenFromDragDrop

      public PivotTableModel addHiddenFromDragDrop(String... hiddenFromDragDrop)
      Adds attribute names to omit from the drag'n'drop portion of the UI.

      Applies only when editable=true.

      Parameters:
      hiddenFromDragDrop - attribute names to omit from the drag'n'drop portion of the UI
      Returns:
      a reference to this object
    • getColumnOrder

      public ColumnOrder getColumnOrder()
      Returns:
      the order in which column data is provided to the renderer
    • setColumnOrder

      public PivotTableModel setColumnOrder(ColumnOrder columnOrder)
      Sets the order in which column data is provided to the renderer.

      Ordering by value orders by column total.

      Parameters:
      columnOrder - the order in which column data is provided to the renderer
      Returns:
      a reference to this object
    • getRowOrder

      public RowOrder getRowOrder()
      Returns:
      the order in which row data is provided to the renderer
    • setRowOrder

      public PivotTableModel setRowOrder(RowOrder rowOrder)
      Sets the order in which row data is provided to the renderer.

      Ordering by value orders by row total.

      Parameters:
      rowOrder - the order in which row data is provided to the renderer
      Returns:
      a reference to this object
    • getMenuLimit

      public Integer getMenuLimit()
      Returns:
      the maximum number of values to list in the double-click menu
    • setMenuLimit

      public PivotTableModel setMenuLimit(Integer menuLimit)
      Sets the maximum number of values to list in the double-click menu.

      Applies only when editable=true.

      Parameters:
      menuLimit - the maximum number of values to list in the double-click menu
      Returns:
      a reference to this object
    • getAutoSortUnusedProperties

      public Boolean getAutoSortUnusedProperties()
      Returns:
      whether or not unused attributes are kept sorted in the UI
    • setAutoSortUnusedProperties

      public PivotTableModel setAutoSortUnusedProperties(Boolean autoSortUnusedProperties)
      Original property name: autoSortUnusedAttrs.

      Sets whether or not unused attributes are kept sorted in the UI.

      Applies only when editable=true.

      Parameters:
      autoSortUnusedProperties - whether or not unused attributes are kept sorted in the UI
      Returns:
      a reference to this object
    • getUnusedPropertiesVertical

      public UnusedPropertiesVertical getUnusedPropertiesVertical()
      Returns:
      whether or not unused attributes are shown vertically
    • setUnusedPropertiesVertical

      public PivotTableModel setUnusedPropertiesVertical(UnusedPropertiesVertical unusedPropertiesVertical)
      Original property name: unusedAttrsVertical.

      Sets whether or not unused attributes are shown vertically instead of the default which is horizontally. true means always vertical, false means always horizontal. If set to a number (as is the default) then if the attributes' names' combined length in characters exceeds the number then the attributes will be shown vertically.

      Applies only when editable=true.

      Parameters:
      unusedPropertiesVertical - whether or not unused attributes are shown vertically
      Returns:
      a reference to this object
    • getDataProvider

      public DataProvider getDataProvider()
      Returns:
      a data provider that contains items which will be shown on PivotTable
    • setDataProvider

      public PivotTableModel setDataProvider(DataProvider dataProvider)
      Sets a data provider for PivotTable. Contains items which will be shown on PivotTable.
      Parameters:
      dataProvider - a data provider that contains items which will be shown on PivotTable
      Returns:
      a reference to this object
    • addData

      public PivotTableModel addData(DataItem... dataItems)
      Adds a data item to the data provider.
      Parameters:
      dataItems - a data item to add
      Returns:
      a reference to this object
    • getFilterFunction

      public JsFunction getFilterFunction()
      Returns:
      a filter function that is called on each record
    • setFilterFunction

      public PivotTableModel setFilterFunction(JsFunction filter)
      Original property name: filter.

      Sets a filter function that is called on each record, returns false if the record is to be excluded from the input before rendering or true otherwise.

      Parameters:
      filter - a filter function that is called on each record
      Returns:
      a reference to this object
    • getSortersFunction

      public JsFunction getSortersFunction()
      Returns:
      a sorter function
    • setSortersFunction

      public PivotTableModel setSortersFunction(JsFunction sorters)
      Original property name: sorters.

      Sets a sorter function that is called with an attribute name and can return a function which can be used as an argument to Array.sort for output purposes. If no function is returned, the default sorting mechanism is a built-in "natural sort" implementation. Useful for sorting attributes like month names.

      Parameters:
      sorters - a sorter function
      Returns:
      a reference to this object
    • getRendererOptions

      public RendererOptions getRendererOptions()
      Returns:
      an object that is passed through to renderer as options
    • setRendererOptions

      public PivotTableModel setRendererOptions(RendererOptions rendererOptions)
      Sets an object that is passed through to renderer as options.
      Parameters:
      rendererOptions - an object that is passed through to renderer as options
      Returns:
      a reference to this object
    • getInclusions

      public Map<String,List<String>> getInclusions()
      Returns:
      a map whose keys are attribute names and values are arrays of attribute values
      See Also:
    • setInclusions

      public PivotTableModel setInclusions(Map<String,List<String>> inclusions)
      Sets a map whose keys are attribute names and values are arrays of attribute values which denote records to include in rendering; used to prepopulate the filter menus that appear on double-click (overrides exclusions).

      Applies only when editable=true.

      Parameters:
      inclusions - a map whose keys are attribute names and values are arrays of attribute values
      Returns:
      a reference to this object
      See Also:
    • setInclusions

      public PivotTableModel setInclusions(String property, List<String> inclusions)
      Sets a list whose values are arrays of attribute values which denote records to include in rendering; used to prepopulate the filter menus that appear on double-click (overrides exclusions).

      Applies only when editable=true.

      Parameters:
      property - a property for which set inclusions
      inclusions - a list of property values
      Returns:
      a reference to this object
      See Also:
    • addInclusions

      public PivotTableModel addInclusions(String property, String... inclusions)
      Adds property values to a given property which denote records to include in rendering; used to prepopulate the filter menus that appear on double-click (overrides exclusions).

      Applies only when editable=true.

      Parameters:
      property - a property for which set inclusions
      inclusions - an array of property values
      Returns:
      a reference to this object
      See Also:
    • getExclusions

      public Map<String,List<String>> getExclusions()
      Returns:
      a map whose keys are attribute names and values are arrays of attribute values
    • setExclusions

      public PivotTableModel setExclusions(Map<String,List<String>> exclusions)
      Sets a map whose keys are attribute names and values are arrays of attribute values which denote records to exclude from rendering; used to prepopulate the filter menus that appear on double-click.

      Applies only when editable=true.

      Parameters:
      exclusions - a map whose keys are attribute names and values are arrays of attribute values
      Returns:
      a reference to this object
      See Also:
    • setExclusions

      public PivotTableModel setExclusions(String property, List<String> exclusions)
      Sets a list whose values are arrays of attribute values which denote records to exclude from rendering; used to prepopulate the filter menus that appear on double-click.

      Applies only when editable=true.

      Parameters:
      property - a property for which set exclusions
      exclusions - a map whose keys are attribute names and values are arrays of attribute values
      Returns:
      a reference to this object
      See Also:
    • addExclusions

      public PivotTableModel addExclusions(String property, String... exclusions)
      Adds property values to a given property which denote records to exclude from rendering; used to prepopulate the filter menus that appear on double-click.

      Applies only when editable=true.

      Parameters:
      property - a property for which set exclusions
      exclusions - a map whose keys are attribute names and values are arrays of attribute values
      Returns:
      a reference to this object
      See Also:
    • getDerivedProperties

      public DerivedProperties getDerivedProperties()
      Returns:
      an object that represents derived properties
    • setDerivedProperties

      public PivotTableModel setDerivedProperties(DerivedProperties derivedProperties)
      Original property name: derivedAttributes.

      Sets an object that represents derived properties (see documentation).

      Parameters:
      derivedProperties - an object that represents derived properties
      Returns:
      a reference to this object
    • getLocaleCode

      public String getLocaleCode()
      Returns:
      a locale code
    • setShowUI

      public void setShowUI(Boolean showUI)
      Shows or hides UI. true by default.
      Applies only when editable=true.
      Parameters:
      showUI - show UI option
    • isShowUI

      public Boolean isShowUI()
      Returns:
      whether or not UI is shown
    • setShowRowTotals

      public void setShowRowTotals(Boolean rowTotals)
      Shows or hides row totals. true by default.
      Parameters:
      rowTotals - row totals option
    • isShowRowTotals

      public Boolean isShowRowTotals()
      Returns:
      whether or not row totals is shown
    • setShowColTotals

      public void setShowColTotals(Boolean colTotals)
      Shows or hides col totals. true by default.
      Parameters:
      colTotals - col total options
    • isShowColTotals

      public Boolean isShowColTotals()
      Returns:
      whether or not col totals is shown
    • setLocaleCode

      public PivotTableModel setLocaleCode(String localeCode)
      Sets a locale code
      Parameters:
      localeCode - a locale code
      Returns:
      a reference to this object
    • getWiredFields

      public List<String> getWiredFields()