Saving tableView "state" to layout

Is it possible to save tableView “state” to the layout on layout save?

For example we would like to save the:

  • columns sorted by
  • “filter”
  • colorised cells
  • etc.?

All of these are quite different:

  • Columns sorted by - it would make sense for the platform to support it by default. I’ve just created a ticket for that.
  • Filter state - I would argue that it shouldn’t be part of a layout, since it’s too easy to unintentionally hide the data for the future users (but see “etc” point for a solution).
  • Colorized cells - it is part of the layout already (if a built-in mechanism for color-coding is used).
  • Etc - indeed, it would be quite convenient to be able to save arbitrary data along with the layout, and use it at a later time when a layout is applied. This way, the application developer will have complete control over what and how is being saved. In order to do that, we will likely introduce a number of events that could be intercepted; stay tuned, we’ll provide updates in this topic.
1 Like

We’ve just added these three events to let the developer control what is being saved as part of the layout, and intercept the application of the layout. Note that when handling the onViewLayoutGenerated and onViewLayoutApplying, it’s possible to change the layout by assigning the layout.viewState field.

// open a table, then do View | Layout | Clone to see what's happening
function info(action, layout) {`${action}: ${layout.viewState}`); } => info('generated', layout)); => info('applying', layout)); => info('applied', layout));

Next to come: a field for storing the additional (app-specific, etc) information.

Thanks for providing these events. Am I right we could use the property API to save arbitrary data to the a layout and use this information later, right?

In any case, what are the limitations of the property API? In the past I was running into some issues when I was trying to save non-string data to the property API?

Properties API currently supports only string data.
But you can save additional information to ViewLayout.userData field (serialized to string).
NOTE: This field can be renamed in the future, we will notify you.