setExpandNode in treeView

Hi

onShow of a form we load a dataset into a treeView (servoy-extra component). Then we call setExpandNode and receive the warning

WARN com.servoy.j2db.server.ngclient.api - You are calling a component sync api method (to browser) in form ‘XY’ before the form is available in browser’s DOM. This should be avoided.

Is there a hook, where we can call setExpandNode? A hook after the form is available in the DOM? Like ‘afterAvailable’?

Thanks and regards
Birgit

Hi Birgit,

Some components like treeView and dataGrid do have an onReady eventhandler.
onReady will be triggered as soon as the full DOM is ready.

Hope this helps.

Hi Marc

Thank you for the answer. I actually did try with onReady, but the event is triggered continuously, not just once. Do you know, how I can unregister the event, if it got triggered the first time?

Best regards
Birgit

The onReady should only be triggered once.
If it’s triggered continuously, there might be something else that is causing that behaviour.

So: no, I don’t know how to unregister, as this should not be necessary.

Hi Marc

Thank you for the hint with onReady. Good to know, that it should work.
I’ll simplify my form and check, if triggering stops. To figure out what fires the event.

Thanks and kind regards
Birgit

if everything else fails, a form-variable that you check in the function and set after running the first time could help.