Dynamic number of input fields

Hi Knimers,
I would like to have a dynamic number of input fields depending on what the user selects. As you can see in the screenshot, e.g. the user selects 4, then the string inputs “Parameter Value” and “Parameter Path” should dynamically grow and shrink to 4 or whatever the user selects.


I’m currently trying with a loop, but that doesn’t work:

I would be happy if anyone has any ideas or solutions.

Best regards,
Martin

Hi @mkammerer,

I’d suggest to not make the two input fields, which should dynamically change based on the first choice, adjustable and instead just concatenate and display a string for both options.

Reason why I am suggesting this is that the current logic would also require to change any other input field, like #1 and #3, if #2 changes. So if all basically have the same value, there is no point in making it unnecessarily complex.

Best
Mike

Hi Martin,

I know it’s been a little while since you posted this but here’s an example that might help you.

KNIME can’t dynamically create widgets (would be really cool feature addition if possible) so you have to add as many input widgets as your maximum choice (6 in your example).

Then set them up as optional using a case statement. If the widget is bypassed you won’t see it in the interface.

Optional String Inputs.knwf (95.7 KB)

Good luck,
Troy

2 Likes

Troy has a good option → if you know the maximum number of options a user could select then you could hide/show like has.

If you don’t know the maximum you could loop through each input, or make the input an editable table instead of string widgets.