It is advisable creating a separate method and call it when needed, thus the code will look more transparent and easy to be maintained.
Initially, the reason the method did not work was because the column.menu
property takes a boolean value and a function declaration was passed to it. To make it work, the function needs to be executed, and for that, place the round brackets to end of it. (see marked with yellow)
You can also try the Dojo Sample
for a Live demonstration.