Well, there is no such functionality in a AccordionLayout.
I will try to prepare an example when you answer my question below.
Please clarify why do you need to do these actions on a server side?
I should understand it to suggest a solution.
Hmm, I tested the example again - both toolbars are not hidden for me in all cases.