At Infinite Table, we continued our work on preparing for our Autumn release, focusing mainly on adding new functionalities and documenting them thoroughly, together with enhancements to existing features.
Summary
We have implemented a few new functionalities:
And we have updated some of the existing features:
- group columns inherit styles and configuration
- column hiding when grouping
- group columns can be bound to a field
- using the column valueGetter in sorting
Coming soon
We started working on column and context menus.
We will first release fully customizable column menus to show/hide columns and to easily perform other operations on columns.
This will be followed by context menus where you will be able to define your own custom actions on rows/cells in the table.
Don't worry, the menus will be fully customizable, the menu items are fully replaceable with whatever you need, or you will be able to swap our menu component with a custom one of your own.
New Features
Here's what we shipped in the month of August:
Row Selection
Row selection can be single or multiple, with or without a checkbox, with or without grouping and for a lazy or non-lazy DataSource
- ๐
that was a long enumeration, but seriously, we think we got something great out there.
You can specify the selection via the rowSelection (controlled) or defaultRowSelection (uncontrolled) props, and listen to changes via the onRowSelectionChange callback prop.
This example shows how you can use multiple row selection with a predefined controlled value.
Go ahead and select some groups/rows and see the selection value adjust.
The example also shows how you can use the InfiniteTableApi to retrieve the actual ids of the selected rows.
Find out more on row selection - single vs multiple selection, grouped or ungrouped data, checkbox selection, lazy selection - read about all the possible combinations you can use to fit your needs.
Column Rendering Pipeline
The rendering pipeline for columns is a series of functions defined on the column that are called while rendering.
Most of those functions existed even before, but piping the return values from one to the other was not available. We think this is a big deal and opens up lots of use-cases.
All the columns that have render
in their name, will be called with an object that has a renderBag
property on it, which contains the values that the previous function in the pipeline returned.
For example:
const column: InfiniteTableColumn<T> = {
valueGetter: ({ data, field }) => {
return data[field] * 10
},
renderValue: ({ value, renderBag })=> {
// accessing `value` here would give us the result from `data[field]`
// but using `renderBag.value` would give us `data[field] * 10`,
// namely the result of the previous function in the pipeline
}
}
Second example:
const column: InfiniteTableColumn<T> = {
renderGroupIcon: ({ renderBag }) => {
// we can use `renderBag.groupIcon` to have access to the default group icon and decorate it
return <b style={{ padding: 10 }}>
{renderBag.groupIcon}
</b>
},
render: ({ renderBag })=> {
// allows you to fully customize the end-result
<>
{renderBag.value}
{renderBag.groupIcon}
{renderBag.selectionCheckBox}
</>
}
}
These are all the properties available in the renderBag
object:
value
groupIcon
selectionCheckBox
Here is the full list of the functions in the rendering pipeline, in order of invocation:
-
columns.valueGetter - doesn't have access to
renderBag
-
columns.valueFormatter - doesn't have access to
renderBag
-
columns.renderGroupIcon - can use all properties in
renderBag
-
columns.renderSelectionCheckBox - can use all properties in
renderBag
-
columns.renderValue - can use all properties in
renderBag
-
columns.renderGroupValue - can use all properties in
renderBag
-
columns.renderLeafValue - can use all properties in
renderBag
-
columns.render - can use all properties in
renderBag
.
Additionally, thecolumns.components.ColumnCell custom component has access to the renderBag
via useInfiniteColumnCell
Sortable Group Columns
When groupRenderStrategy is used, the group column is sortable by default if all the columns that are involved in grouping are sortable.
Sorting the group column makes the sortInfo
have a value that looks like this:
const sortInfo = [
{ field: ['stack','age'], dir: 1, id: 'group-by', }
]
When groupRenderStrategy="multi-column", each group column is sortable by default if the column with the corresponding field is sortable.
In both single and multi group column render strategy, the columns.sortable property can be used to override the default behavior.
Updated Features
Hereโs a list of Infinite Table functionalities that we enhanced in the last month:
Enhanced Group Columns
Group columns now inherit configuration from the columns bound to the field they are grouped by - if such columns exist.
In this example, the group column inherits the styling of the country
column, because the country
field is used for grouping.
The generated group column(s) - can be one for all groups or one for each group - will inherit the style
/className
/renderers from the columns corresponding to the group fields themselves (if those columns exist).
Additionally, there are other ways to override those inherited configurations, in order to configure the group columns:
- use groupBy.column to specify how each grouping column should look for the respective field (in case of groupRenderStrateg="multi-column"
- use groupColumn prop
- can be used as an object - ideal for when you have simple requirements and when groupRenderStrateg="single-column"
- as a function that returns a column configuration - can be used like this in either single or multiple group render strategy
Column Hiding when Grouping
When grouping is enabled, you can choose to hide some columns. Here are the two main ways to do this:
- use hideColumnWhenGrouped - this will make columns bound to the group fields be hidden when grouping is active
- use columns.defaultHiddenWhenGroupedBy (also available on the column types, as columnTypes.defaultHiddenWhenGroupedBy) - this is a column-level property, so you have more fine-grained control over what is hidden and when.
Valid values for columns.defaultHiddenWhenGroupedBy are:
-
"*"
- when any grouping is active, hide the column that specifies this property -
true
- when the field this column is bound to is used in grouping, hides this column -
keyof DATA_TYPE
- specify an exact field that, when grouped by, makes this column be hidden -
{[k in keyof DATA_TYPE]: true}
- an object that can specify more fields. When there is grouping by any of those fields, the current column gets hidden.
In this example, the column bound to firstName
field is set to hide when any grouping is active, since the group column is anyways found to the firstName
field.
In addition, hideColumnWhenGrouped is set to true
, so the stack
and preferredLanguage
columns are also hidden, since they are grouped by.
Group Columns Bound to a Field
Group columns can now be bound to a field, by leveraging the (obviously ...) property. This will make the group column render the value of that field for non-group rows.
In addition, you can now use columns.renderGroupValue and columns.renderLeafValue for configuring the rendered value for grouped vs non-grouped rows.
Column valueGetter in Sorting
Columns allow you to define a columns.valueGetter to change the value they are rendering (eg: when the DataSet
has nested objects). Previously, this value returned by columns.valueGetter was not used when sorting the table. With the latest updated, the value returned by valueGetter
is correctly used when sorting the grid locally.
Top comments (2)
This is impressive stuff. Super fast too.
Is this released and what is the licence?
Thanks for the feedback!
Yes, it's public on npm already, we're in beta as we need to add a few more functionalities before the big launch ad the end of the month, but it's already production ready and stable and used by some companies in the wild.
It has dual license - read more about it here infinite-table.com/docs/latest/lea...