Hi
I have a CDS/Dataverse datasource, and in a gallery I display a table/entity, with some fields, here among an optionset.
I want to be able to filter the gallery based on a textinput field, and the field that should be filteren on is the optionset field.
So if we on the entity/table have an optionset with possible values (Bathroom, Storage, Livingroom, Enterence), if we then enter "room" in the textinput, the gallery will be filtered to only show records that have the opstionset set to "Bathroom" or "Livingroom".
Solved! Go to Solution.
Hi @m_jeppesen ,
Firstly, the data type of the optionset field is not “text”. But the data type of textinput control is “text”. So you could not use string to search for the record you want.
Therefore, it is difficult to use the textinput control directly to filter the optionset field.
Secondly, dropdown control supports optionsetfield. So you could use the dropdown control to filter the optionset field.
So , I suggest you set the default value of dropdown control by judging the input of textinput control.
For example:
When typing "Bathroom" into the textinput control, the dropdown control selects the "Bathroom" option by default.
Gallery filters records through the item selected by the dropdown control.
Finally, hide the dropdown control. The textinput control can filter records indirectly.
According to your description ,I've made a test for your reference.The point is to use three controls to meet your needs. They are textinput control, dropdown control and gallery control.
1\ This is my entity “Test2S”
2\ Add a textinput control “TextInput1”.
3\ Add a dropdown control “Dropdown1” and set its Items property to:
Choices(Test2S.Optionset)
Set Dropdown1 ‘s Default property to:
If(
TextInput1.Text = "Bathroom",
Last(
FirstN(
Test2S,
1
)
).Optionset,
TextInput1.Text = "Storage",
Last(
FirstN(
Test2S,
2
)
).Optionset,
TextInput1.Text = "Livingroom",
Last(
FirstN(
Test2S,
3
)
).Optionset,
TextInput1.Text = "Enterence",
Last(
FirstN(
Test2S,
4
)
).Optionset
)
Set Dropdown1 ‘s Visible property to:
false
4\ Add a gallery control and set its Items property to:
Filter(Test2S,Optionset=Dropdown1.Selected.Value)
5\ The result is as follows:
In addition, I suggest you use the drop-down control directly instead of the textinput control.
The advantage is that the code is simpler and easier to maintain.
Best Regards,
Wearsky
Hi @m_jeppesen ,
Firstly, the data type of the optionset field is not “text”. But the data type of textinput control is “text”. So you could not use string to search for the record you want.
Therefore, it is difficult to use the textinput control directly to filter the optionset field.
Secondly, dropdown control supports optionsetfield. So you could use the dropdown control to filter the optionset field.
So , I suggest you set the default value of dropdown control by judging the input of textinput control.
For example:
When typing "Bathroom" into the textinput control, the dropdown control selects the "Bathroom" option by default.
Gallery filters records through the item selected by the dropdown control.
Finally, hide the dropdown control. The textinput control can filter records indirectly.
According to your description ,I've made a test for your reference.The point is to use three controls to meet your needs. They are textinput control, dropdown control and gallery control.
1\ This is my entity “Test2S”
2\ Add a textinput control “TextInput1”.
3\ Add a dropdown control “Dropdown1” and set its Items property to:
Choices(Test2S.Optionset)
Set Dropdown1 ‘s Default property to:
If(
TextInput1.Text = "Bathroom",
Last(
FirstN(
Test2S,
1
)
).Optionset,
TextInput1.Text = "Storage",
Last(
FirstN(
Test2S,
2
)
).Optionset,
TextInput1.Text = "Livingroom",
Last(
FirstN(
Test2S,
3
)
).Optionset,
TextInput1.Text = "Enterence",
Last(
FirstN(
Test2S,
4
)
).Optionset
)
Set Dropdown1 ‘s Visible property to:
false
4\ Add a gallery control and set its Items property to:
Filter(Test2S,Optionset=Dropdown1.Selected.Value)
5\ The result is as follows:
In addition, I suggest you use the drop-down control directly instead of the textinput control.
The advantage is that the code is simpler and easier to maintain.
Best Regards,
Wearsky
Thanks @v-xiaochen-msft
Not the most smooth solution, but that's really not your fault 😉
User | Count |
---|---|
250 | |
102 | |
94 | |
47 | |
37 |