@serenity-is/sleekgrid / GroupItemMetadataProvider
Class: GroupItemMetadataProvider
Defined in: src/data/groupitemmetadataprovider.tsx:88
Grid plugin that provides row metadata and formatters for group headers and
group totals rows. Handles expand/collapse UI via click and keyboard
(Space, +, -) and delegates metadata through getGroupRowMetadata /
getTotalsRowMetadata for use by DataView.
Implements
Constructors
Constructor
new GroupItemMetadataProvider(
opt?):GroupItemMetadataProvider
Defined in: src/data/groupitemmetadataprovider.tsx:117
Creates a new provider.
Parameters
opt?
GroupItemMetadataProviderOptions
Partial options merged with GroupItemMetadataProvider.defaults.
Returns
GroupItemMetadataProvider
Properties
getGroupRowMetadata()
getGroupRowMetadata: (
item) =>ItemMetadata
Defined in: src/data/groupitemmetadataprovider.tsx:548
Returns row metadata for a group header row. The grid/DataView calls this to obtain CSS classes, focusability and the spanned column formatter.
Parameters
item
Group row item.
Returns
Metadata describing how the group row should be rendered.
getTotalsRowMetadata()
getTotalsRowMetadata: (
item) =>ItemMetadata
Defined in: src/data/groupitemmetadataprovider.tsx:677
Returns row metadata for a group totals row.
Parameters
item
Totals row item.
Returns
Metadata describing how the totals row should be rendered.
grid
protectedgrid:ISleekGrid
Defined in: src/data/groupitemmetadataprovider.tsx:90
Host grid instance set during GroupItemMetadataProvider.init.
pluginName
readonlypluginName:"GroupItemMetadataProvider"="GroupItemMetadataProvider"
Defined in: src/data/groupitemmetadataprovider.tsx:243
Plugin name used for lookup via grid.getPluginByName().
Implementation of
defaults
readonlystaticdefaults:GroupItemMetadataProviderOptions
Defined in: src/data/groupitemmetadataprovider.tsx:128
Default option values. Override per instance via constructor or GroupItemMetadataProvider.setOptions.
maxIndentLevel
staticmaxIndentLevel:number=8
Defined in: src/data/groupitemmetadataprovider.tsx:100
The deepest grouping level that has an indentation rule in css/slick.grid.css, which
defines the rules for levels 1 to 8, as CSS can't multiply a custom property by a level
that is only known at runtime. Deeper levels are clamped to it. If you need more levels,
add the matching .slick-group-level-N rules to your own stylesheet and raise this value.
Methods
destroy()
destroy():
void
Defined in: src/data/groupitemmetadataprovider.tsx:248
Detaches event handlers added during GroupItemMetadataProvider.init.
Returns
void
Implementation of
getDataRowMetadata()
getDataRowMetadata(
row,level,baseMetadata?):ItemMetadata
Defined in: src/data/groupitemmetadataprovider.tsx:600
Returns row metadata for a data row that is inside one or more groups. Views that support grouping call this for their data rows and merge the result with their own metadata (see mergeMetadata).
When GroupItemMetadataProviderOptions.indentDataRows is true, the first cell
gets the level class (e.g. slick-group-level-2) and css/slick.grid.css indents it by
level * var(--sg-group-indent), so the data rows of nested groups line up under their
group rows. No inline style is used, so that it works with a content security policy
that disallows inline styles.
Parameters
row
number
The row index of the data row in the view.
level
number
The grouping level of the data row. Data rows are normally at the leaf level, i.e. the number of active groupings, so two levels of grouping indent them by two steps.
baseMetadata?
Metadata the view has already built for the row, e.g. from its
getItemMetadata callback. It is merged with the indentation metadata when the row is
indented, and returned as is otherwise.
Returns
Metadata for the row, or null when there is none and the row is not indented.
getFocusableCellRange()
protectedgetFocusableCellRange(grid,row):object
Defined in: src/data/groupitemmetadataprovider.tsx:309
Returns the first and the last cell of a row that can be navigated to, ignoring the columns a cell spans. The arrow keys are only used for the group at these ends of the row, as they don't go to another cell there.
Parameters
grid
The grid that shows the row.
row
number
The row to find the cells of.
Returns
object
The first and the last navigable cell, both null when there is none.
first
first:
number
last
last:
number
getOptions()
getOptions():
GroupItemMetadataProviderOptions
Defined in: src/data/groupitemmetadataprovider.tsx:259
Returns the current resolved options.
Returns
GroupItemMetadataProviderOptions
Current options object.
getTotalsDisplay()
getTotalsDisplay(
level?):boolean|"groupheader"
Defined in: src/data/groupitemmetadataprovider.tsx:413
Returns where the totals of a group of the given level are shown, which the view that groups the rows knows: on a row of their own, on the row of the group itself, or not at all. It defaults to a row of their own when the view doesn't tell, like the grouping defaults of a view.
Parameters
level?
number
The level of the grouping, 0 when not given.
Returns
boolean | "groupheader"
true for a totals row, "groupheader" for the row of the group, false for none.
groupCellPosition()
groupCellPosition(
level?):object
Defined in: src/data/groupitemmetadataprovider.tsx:482
Computes the cell index and colspan for the spanned group cell, taking summary columns, columns
marked with skipGroupCell, narrow fixed width columns and frozen columns into account.
Parameters
level?
number
The level of the grouping, which decides where the totals of a group are shown.
Returns
object
Object with cell start index and colspan span width ("*" when the totals are not
on the row of the group, so that the group cell spans the rest of the row).
cell
cell:
number
colspan
colspan:
number|"*"
handleGridClick()
handleGridClick(
e):void
Defined in: src/data/groupitemmetadataprovider.tsx:275
Click handler that toggles group collapse when the toggle element is clicked.
Parameters
e
Cell mouse event from the grid's onClick.
Returns
void
handleGridKeyDown()
handleGridKeyDown(
e):void
Defined in: src/data/groupitemmetadataprovider.tsx:332
Key handler that toggles group collapse on Space / + / - when the group cell is active, and
on the arrow keys at the ends of a group row, e.g. Left collapses the group on the first cell of
its row and Right expands it on the last one.
Parameters
e
Cell keyboard event from the grid's onKeyDown.
Returns
void
init()
init(
grid):void
Defined in: src/data/groupitemmetadataprovider.tsx:236
Initializes the plugin, attaching click and key handlers for expand/collapse.
Parameters
grid
Host grid instance.
Returns
void
Implementation of
isFixedNarrowColumn()
protectedisFixedNarrowColumn(column):boolean
Defined in: src/data/groupitemmetadataprovider.tsx:457
Returns whether a column has a fixed width narrower than
GroupItemMetadataProviderOptions.minGroupCellWidth, which marks a utility column
like a checkbox or a row number column. The declared width is used, as the current one
changes with forceFitColumns and resizing, which would move the group cell column.
A width of 0 is treated as not set, like the column sizing code does, e.g. the fitting of
the columns uses maxWidth || Infinity, so a column with a zero minimum and maximum is a
normal column that can be resized and is not skipped.
Parameters
column
The column to test.
Returns
boolean
true if the column is a narrow column with a fixed width.
isGroupCellColumn()
isGroupCellColumn(
column):boolean
Defined in: src/data/groupitemmetadataprovider.tsx:427
Returns whether a column can be the start of a group cell, and so the column the data rows
of a group are indented in. Summary columns are skipped, as they show the totals of a group,
and so are the columns marked with skipGroupCell and the narrow columns with a fixed width
(see GroupItemMetadataProviderOptions.minGroupCellWidth), like a checkbox column,
which stay in front of the group cell.
Parameters
column
The column to test.
Returns
boolean
true if the group cell can start at the column.
isSkippedColumn()
protectedisSkippedColumn(column):boolean
Defined in: src/data/groupitemmetadataprovider.tsx:441
Returns whether a column stays in front of the group cell, i.e. it is marked with
skipGroupCell, or it is a narrow column with a fixed width, like a checkbox or a row number
column. Such columns keep their own cell in the rows of a group, where the group cell, and the
indentation of the data rows, start after them.
Parameters
column
The column to test.
Returns
boolean
true if the group cell starts after the column.
setGrid()
setGrid(
grid):void
Defined in: src/data/groupitemmetadataprovider.tsx:221
Sets the grid the provider reads the columns from, e.g. to find the column a group cell starts
at, without attaching the event handlers of init. A view that has a grid attached, like
VirtualScrollView, calls it; a provider registered with registerPlugin gets the grid from
init.
Parameters
grid
The grid that shows the rows the provider gives metadata for.
Returns
void
setOptions()
setOptions(
value):void
Defined in: src/data/groupitemmetadataprovider.tsx:267
Merges the given values into the current options.
Parameters
value
GroupItemMetadataProviderOptions
Partial options to apply.
Returns
void
clampIndentLevel()
staticclampIndentLevel(level):number
Defined in: src/data/groupitemmetadataprovider.tsx:109
Clamps a grouping level to GroupItemMetadataProvider.maxIndentLevel, so that a level that has no CSS rule still gets the deepest indentation instead of none. Level 0, the top level groups, is not indented, and has no CSS rule.
Parameters
level
number
The grouping level.
Returns
number
The level, between 0 and GroupItemMetadataProvider.maxIndentLevel.
defaultGroupFormat()
staticdefaultGroupFormat(ctx,opt?):FormatterResult
Defined in: src/data/groupitemmetadataprovider.tsx:154
Default group row formatter. Renders the group title with an optional
expand/collapse toggle indented by group.level.
Parameters
ctx
Formatter context whose item is the Group to render.
opt?
GroupItemMetadataProviderOptions
Options controlling indentation and toggle classes; defaults to GroupItemMetadataProvider.defaults.
Returns
Rendered group row content as DOM/JSX.
defaultTotalsFormat()
staticdefaultTotalsFormat(ctx,grid?):FormatterResult
Defined in: src/data/groupitemmetadataprovider.tsx:198
Default totals row formatter. Delegates to the grid's column totals formatter
(or the column's own groupTotalsFormat/groupTotalsFormatter).
Parameters
ctx
Formatter context whose item is the IGroupTotals row.
grid?
Optional grid fallback when ctx.grid is unavailable.
Returns
Rendered totals content, or empty string when no formatter is found.
mergeMetadata()
staticmergeMetadata(base,extra):ItemMetadata
Defined in: src/data/groupitemmetadataprovider.tsx:633
Merges metadata returned for a row, e.g. the metadata a view or a column provider has
already built and the metadata getDataRowMetadata returns, into a single object.
CSS classes are concatenated, other properties of extra win.
Parameters
base
The metadata built by the view or a user callback, if any.
extra
The metadata to apply on top of it, if any.
Returns
The merged metadata, or null when both arguments are empty.