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) { grok.shell.info(`${action}: ${layout.viewState}`); }

grok.events.onViewLayoutGenerated.subscribe((layout) => info('generated', layout));
grok.events.onViewLayoutApplying.subscribe((layout) => info('applying', layout));
grok.events.onViewLayoutApplied.subscribe((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.

Hi DG community,

I have an additional question about layout.
Recently we are making project template with layout. The project contains serveral tables such as CSV, excel file and they are connected by primaly key like a RDB.
My question is…
Can layout keep link information of template project? ( Or how to keep / save link information of tables and apply it to other data sources?)
Any commnets or suggestions are greatly appreciated.

Thanks,
Taka

HI,

Yes, table linking data is stored in the project, but not in layout information, but connected with project itself.

1 Like

Hi @alex.paramonov,
Thank you for your prompt reply!
Are there any ways to apply not only layout but also link information of a template to several dataset?
Thanks,

Hi,
Unfortunately, no.

We are now working in Project Layout concept, that allows to join multiple tables layouts and save linking info.