Switching and Sychnronising Layouts

Summary

  • It is possible to syncrhonise the (decreasing) common properties in Table and Pivot Layouts
  • It is not advisable to create one Layout and switch between Pivot and Table at runtime

Switching Layout Types

It is common for an application to include both Table and Pivot Views.

The temptation for many developers is to create a single Layout and update it each time the user switches view.

In earlier versions of AdapTable this made good sense as the 2 objects were very similar.

However while this technically is possible (by using updateLayout in LayoutAPI), it is no longer recommended.

Caution

  • When switching between Pivot and Table view, try to avoid mutating / updating the same Layout
  • Instead try to have 2 Layouts of a similar name and synchronise the common properties in your code - see below

The Table Layout and Pivot Layout objects are now very different, with fewer common properties, and this will increasingly become the case as new functionality is added in line with users's requests.

Sychnronising Layouts

Another common use case is to synchronise common elements (e.g. Filters) between Pivot and Table Layouts.

There are a few ways to accomplish this, but perhaps the best is to leverage the Layout Changed Event to keep properties in sync between the 2 Layouts.

Synchronising Layouts
Fork
  • In this example we have 3 Layouts (1 Table, 1 Pivot and 1 Row Grouped) and we ensure that Column Filters and the Grid Filter is kept consistent between them
Try It Out
  • In any Layout click the "Add Filters" button to create Grid and Columns Filters, and switch Layouts to see how the Filters in that Layout were updated simultaneously