Switching and Synchronising Layouts

View as Markdown

Summary

  • It is possible to synchronise 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

Find Out More

Layouts · Topics in this Section. Table vs pivot definitions — Table Layouts and Pivot Layouts.

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.

That is possible (by using updateCurrentLayout in Layout API), but it is not 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 very different, with fewer common properties.

Synchronising 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
Loading demo…