Providing Default Layout Properties
Summary
- AdapTable provides default Layout properties which will be used in all Layouts created at run-time
- Additional props can be applied to all Layouts (new & existing) to enhance / extend functionality seamlessly
- The State Options functions can be leveraged to define these props at design-time for greater flexibility
AdapTable enables developers to configure default properties for both Table and Pivot Layouts.
These are then applied automatically to Layouts created at runtime.
Additionally, developers can extend all Layouts (new and existing) with custom properties to enhance functionality or patch existing configurations seamlessly.
Caution
- This is different to the Default Layout that versions of AdapTable (prior to v.20) offered but which was removed
- That was a full-blown Layout which AdapTable created if none was supplied
Default Creation Properties
Default creation properties are applied automatically to all new Table and Pivot Layouts created at runtime.
These properties ensure consistency across newly created Layouts without requiring manual configuration.
Note
- Layouts created through Layout API will contain these properties (unless the property is explicitly overridden)
- Layouts created via the UI wil show these properties in the Layout Wizard (allowing the user to change them)
This is done using the layoutCreationDefaultProperties property in Layout Options.
layoutCreationDefaultProperties
- In this example we have provided default creation properties for both Table and Pivot Layouts:
- For Table Layouts - we default a on
NameColumn, and a Column Filter onLanguageColumn - For Pivot Layouts - we default Aggregations on
Github StarsandGithub WatchersColumns (suppressing the Agg Func), a GrandTotalRow at bottom and a PivotGrandTotal Column before
- For Table Layouts - we default a on
- In the Layout Toolbar click to add a new Table Layout and note that the new Layout already contains the Column Sort and Column Filter defined in default props
- Then click to add a new Pivot Layout and note that the new Layout already contains the Aggregations, GrandTotalRow and PivotGrand Total Column
Extending Initial State Layouts
AdapTable allows developers to enhance all Layouts (new and existing) by manipulating the Layout State.
This is most easily achieved by leveraging 2 State Options functions:
applyState- modifies the Layout state dynamicallysaveState- controls how Layouts are persisted to avoid polluting the saved state with default configurations
- This example demonstrates how to create default layout properties in Initial State; we:
- Add a read-only
All ColumnsLayout that includes all available columns with a default sort onname - Prevent the default
All ColumnsLayout from being persisted by filtering it out in thesaveStatefunction in State Options - Apply a default descending sort on the
github_starscolumn to all Layouts that do not contain a sort
- Add a read-only