DEV Community

Infinite Table
Infinite Table

Posted on • Originally published at infinite-table.com

Infinite Table Monthly Update - August 2022

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:

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
  }
}
Enter fullscreen mode Exit fullscreen mode

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}
    </>
  }
}
Enter fullscreen mode Exit fullscreen mode

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:

  1. columns.valueGetter - doesn't have access to renderBag
  2. columns.valueFormatter - doesn't have access to renderBag
  3. columns.renderGroupIcon - can use all properties in renderBag
  4. columns.renderSelectionCheckBox - can use all properties in renderBag
  5. columns.renderValue - can use all properties in renderBag
  6. columns.renderGroupValue - can use all properties in renderBag
  7. columns.renderLeafValue - can use all properties in renderBag
  8. 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', }
]
Enter fullscreen mode Exit fullscreen mode

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:

Column Hiding when Grouping

When grouping is enabled, you can choose to hide some columns. Here are the two main ways to do this:

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)

Collapse
 
jw_13 profile image
James Wilson

This is impressive stuff. Super fast too.
Is this released and what is the licence?

Collapse
 
get_infinite profile image
Infinite Table

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...