Providing defaults for the viewers

Hi team,
we would like to override some default configurations of the viewers, like setting “allowEdit” to false for the Table visualization.
It seems like the API is already supporting overriding configurations.
However, an elegant way would be to set viewer defaults upon an application initialization event, which will then not be specific to one particular instance of a viewer, but more global to the custom application.
Is there a way for doing this?
Thanks

Hi Nico, working on your question.
Soon we will provide an example.

2 Likes

Hi Nico and sorry for the late reply!
For this functionality you can subscribe on the ‘d4-viewer-added’ event at the start of the execution of your application and set the desired configuration like this:

grok.events
    .onEvent('d4-viewer-added')
    .subscribe((args) => {
		if(JSON.parse(args.args.viewer.getOptions()).type == 'Grid')
  	     	args.args.viewer.setOptions({allowEdit: false})
    });

Also, we fixed a bug and now this event will also fire when the default grid is added when the table is loaded. This will work in the next dev-build.

1 Like

Thanks for the pointer. We are already using something similar, but where wondering if there couldn’t be a more formal way to set “default settings” from within an app?

I think the described method is currently the best way for this.

We can introduce customizable global settings that could be managed centrally, but I don’t think the “per app” approach can work, since there could be multiple application running at the time. I see nothing wrong with the approach suggested by @kdoncov , it’s a rather simple and flexible way to customize the platform to your taste.

1 Like