I was wondering if there was a way to do this:
When you select a text input, and start typing, another blank text input is generated below. when you begin typing in that newly generate text input, yet another text input is generated below that one.
Is this possible? To create dynamic forms, or cascading text input fields?
Solved! Go to Solution.
The best way that I know is to add bunch of hidden text boxes, and switch the visibility of them to true once user starts to type in the above text box.
We don't have any way to generate controls dynamically at runtime.
I ran some tests and found some interesting results. The text in a textinput control is tied to the record in the gallery. So Table1 has 100 records and each of those records will maintain its text in the TextInput control even after being filtered.
So if you add or remove a record, any text you have typed is unaffected because our scheme is more of a show/hide--this is welcome news.
To "remove" a textinput field, collect it to a temporary collection by setting the trashcan icon to:
If(CountRows(Gallery1.AllItems)>1, Collect(removed,ThisItem.Number) )
This means, "As long as there is more than one TextInput field, it's okay to remove a given record." This is important because if you remove every record, you have no buttons left to add new ones.
Next, you will need to filter the Gallery more to account for the records removed:
Filter(Table1,Number<=cascade,!(Number exactin removed.Value))
This means, "Show a Number of TextInput controls less than or equal to the cascade variable, yet not including the Numbers you removed."
If you want to save the data you put into the TextInput controls, you will need to use ForAll(Gallery1.AllItems,[actions here]).
For UX, I recommend that you make the height of this gallery variable--let it adjust as more records are shown:
Gallery1.TemplatePadding*(CountRows(Gallery1.AllItems)+1) +70*CountRows(Gallery1.AllItems)
Change 70 to whatever your TemplateSize is so that you get the exact spacing you want.
The best way that I know is to add bunch of hidden text boxes, and switch the visibility of them to true once user starts to type in the above text box.
We don't have any way to generate controls dynamically at runtime.
Yeah i was affraid that was going to be the only way to do it. Thanks for the response!
This can be done.
This is what I'm thinking:
Set(cascade, 1)
Filter(Table1,Number<=cascade)
Set(cascade,cascade+1)
If(ThisItem.Number=Last(Gallery1.AllItems).Number && !IsBlank(Last(Gallery1.AllItems).TextInput1.Text), Set(cascade,cascade+1) )
Set(cascade,cascade-1)
If(ThisItem.Number=Last(Gallery1.AllItems).Number, Set(cascade,cascade-1) )
This scheme should populate an additional text input field each time the TextInput is selected or changed--your choice.
Let me know how it goes.
Edit: the deleting scheme is going to take some more thought--you might end up resetting your TextInput fields if you remove it the way things are right now.
I ran some tests and found some interesting results. The text in a textinput control is tied to the record in the gallery. So Table1 has 100 records and each of those records will maintain its text in the TextInput control even after being filtered.
So if you add or remove a record, any text you have typed is unaffected because our scheme is more of a show/hide--this is welcome news.
To "remove" a textinput field, collect it to a temporary collection by setting the trashcan icon to:
If(CountRows(Gallery1.AllItems)>1, Collect(removed,ThisItem.Number) )
This means, "As long as there is more than one TextInput field, it's okay to remove a given record." This is important because if you remove every record, you have no buttons left to add new ones.
Next, you will need to filter the Gallery more to account for the records removed:
Filter(Table1,Number<=cascade,!(Number exactin removed.Value))
This means, "Show a Number of TextInput controls less than or equal to the cascade variable, yet not including the Numbers you removed."
If you want to save the data you put into the TextInput controls, you will need to use ForAll(Gallery1.AllItems,[actions here]).
For UX, I recommend that you make the height of this gallery variable--let it adjust as more records are shown:
Gallery1.TemplatePadding*(CountRows(Gallery1.AllItems)+1) +70*CountRows(Gallery1.AllItems)
Change 70 to whatever your TemplateSize is so that you get the exact spacing you want.
Hey Mr-dang, this seems like an awesome suggestion! I will have to dedicate some time to see if i can get this to work.
I see what you're saying though, and can't wait to give this a shot!
User | Count |
---|---|
126 | |
87 | |
85 | |
75 | |
69 |
User | Count |
---|---|
215 | |
180 | |
139 | |
97 | |
83 |