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

Sets default properties for new Layouts (Table or Pivot)
Default Creation Props
Fork
  • In this example we have provided default creation properties for both Table and Pivot Layouts:
    • For Table Layouts - we default a on Name Column, and a Column Filter on Language Column
    • For Pivot Layouts - we default Aggregations on Github Stars and Github Watchers Columns (suppressing the Agg Func), a GrandTotalRow at bottom and a PivotGrandTotal Column before
Try It Out
  • 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 dynamically
  • saveState - controls how Layouts are persisted to avoid polluting the saved state with default configurations
Default Layout Props
Fork
  • This example demonstrates how to create default layout properties in Initial State; we:
    • Add a read-only All Columns Layout that includes all available columns with a default sort on name
    • Prevent the default All Columns Layout from being persisted by filtering it out in the saveState function in State Options
    • Apply a default descending sort on the github_stars column to all Layouts that do not contain a sort