Consider the following code
Manipulate[a,
Dynamic@Grid[{
{"Check 1", Control[{{a, 0, ""}, {1, 0}}]},
If[a == 1, {"Check 1.1", Control[{{aa, 0, ""}, {1, 0}}]},
Unevaluated[Sequence[]]],
If[a == 1, {"Check 1.2", Control[{{ab, 0, ""}, {1, 0}}]},
Unevaluated[Sequence[]]]
},
Alignment -> {{Right, Left}, Automatic}],
ControlPlacement -> Left]
Checking Check 1 leads to
Is it possible to use only one If
for both controls Check 1.1 and Check 1.2?
Using Flatten
, for example,
Manipulate[a,
Dynamic@Grid[{
{"Check 1", Control[{{a, 0, ""}, {1, 0}}]},
If[a == 1, Flatten[{
{"Check 1.1", Control[{{aa, 0, ""}, {1, 0}}]},
{"Check 1.2", Control[{{ab, 0, ""}, {1, 0}}]}
}],
Unevaluated[Sequence[]]]
},
Alignment -> {{Right, Left}, Automatic}],
ControlPlacement -> Left]
I get
which is not what I want. I tried playing around with Column
or Row
but no success. Any ideas?
Also, is there a better or faster way of doing something like this? I'm using Dynamic
to be able to do it, but I wonder if Mathematica already has something to do this kind of things.