Page 1 of 1

Enabling a UI control based on VariablesListBox

Posted: Mon Jul 27, 2026 5:27 pm
by vjalby
It's possible to conditionally enable a UI control using the enable keyword.

But when the condition is "a VariablesListBox is filled", I have to use 2 negations, eg

Code: Select all

enable: (!(!group))
Now, I wonder if there's a way to test (without JS) if a VariablesListBox is filled with more than 1 variable ?

Re: Enabling a UI control based on VariablesListBox

Posted: Tue Jul 28, 2026 6:31 pm
by NourEdinDarwish
Hi,

I think you can use js code in enable field directly, I used this for example to check that it is filled with at least one variable

Code: Select all

enable: ({return (ui['subgroupVariables'].value() || []).length > 0;})
I think you can replace the 0 with 1 to satisfy this condition of more than one variable

however, I don't know if this is the best practice here, would be great if Jonathan could comment on it, I think the problem with enable field that it has this special syntax with certain heuristics

Re: Enabling a UI control based on VariablesListBox

Posted: Tue Jul 28, 2026 11:49 pm
by dropmann
Hi, generally we discourage the use of enabling/disabling options unless it's clear to the user what the relationships is (i.e. a checkbox with nested options underneath it) ... you might be better off running the analysis, and presenting a notice at the top, explaining why an option can't be honoured. ... so think if this is the best approach, but if you did want to do this you could do what NourEdinDarwish suggested but these types of situations usually indicate that design wise something is amiss. It can be tricky.

Re: Enabling a UI control based on VariablesListBox

Posted: Wed Jul 29, 2026 7:21 am
by vjalby
Thank you Nour, that's exactly what I was looking for !

@dropmann, I agree with your comment. I'll use it wisely :)