mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #481] Dynamically insert\remove form fields based on other inputs while keeping their order #348
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#348
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @maxiride on GitHub (Jul 30, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/481
In the design of a TUI I have a main and a secondary drop down, based on the selection made on the main one I want to "swap" the secondary drop down accordingly.
ddProdottiis the main one andprodottoSceltois a variable where I assign the correct drop down to use and draw.When the selection on the main dropdown changes I remove the previous field from the form and add the new one, the code works as expected however on the first run I correctly have
whenever the main dropdown selection is changed the new dropdown is redrawn in the last position
-> How can I keep the from consistent when removing and adding elements to it? This is most important when later on I collect the form values using the form fields indexes.
Otherwise is there a reccomended workflow to keep the fields order (hence the indexes) consistent?
@maxiride commented on GitHub (Aug 10, 2020):
Possible duplicate of #192
@rivo commented on GitHub (Sep 15, 2020):
Instead of deleting, then reinserting a new
DropDown, wouldn't it be better to simply update the existing second drop-down withDropDown.SetOptions()? That way, the order will remain the same.@maxiride commented on GitHub (Sep 16, 2020):
Indeed, it is a smarter way to approach it and can't argue with that.