Can I change the target of a listens to widget DataView in nanoflow/js action?

0
I have built a set-up where on the left of the page there is a list of Planning objects. On the right side, a dataview listens to the selection made in that list so that these Plannings can be viewed and edited.   I also have buttons that create a new Planning either from scratch or by duplicating an existing one as a template.   What I want to achieve is that if a user presses such a button, the dataview refreshes as if that user clicked within the list on the newly created object so they can immediately start editing and get instant feedback that their button click did what they wanted it to do.   I think that I could probably achieve this result by reloading the page or refreshing the list and putting the newly created object at the top of the list so it is automatically selected. However, the list is ordered in a way with specific categories such that I do not want every newly created Planning to be placed at the top. Plus, I want to avoid a screen flickering refresh if possible, I just want to redirect what is currently the focus of the dataview on the right.   So, my next thought would be to do it using some javascript shenanigans, but that's not my forte, so I hope someone has had this issue before or in general can help me out!
asked
1 answers
1

Widgets like datagrid2 and gallery don't support the 'listen to' feature yet, so I needed a general workaround which can also help in your scenario.

 

What I did is create a non-persistent helper entity with an association to the target entity (in your case, planning). The on-click action of the list view would then set the association to the target object and refresh the helper object, achieving the same effect.

 

The "Create" button could then create a new object and set the association to the newly created object. 

 

Only thing you need to add is a microflow or nanoflow to open the page. This would create the help object and retrieve the first object from the list view (based on the same xpath & sort order) to ensure that you don't start with an empty right side of the page.

 

Does that help?

answered