DMXzone App Connect Data Traversal Support Product Page
Answered
Apply a filter (or not) if a checkbox is checked
Asked 7 years ago
1
has this question
7 years ago Lee Woolsey posted:
Is is possible to change the value (or ignore) of a Data View filter based if a checkbox is checked.I want to apply a filter (isActive == 1) if a checkbox has been checked, but show all records if it has not. Can I add that condition to my data view?
<dmx-data-view id="student_view" dmx-bind:data="students.data.students" sorton="UserLastName" page="studentPage" pagesize="15" dmx-bind:page="query.studentpage" filter="isActive == 1"></dmx-data-view>
Replies
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
Hi Lee,
Is the "isActive" the filter itself or would you like to use it in order to trigger another filter?
Is the "isActive" the filter itself or would you like to use it in order to trigger another filter?
Replied 7 years ago
7 years ago Lee Woolsey replied:
isActive is the filter, it is a field in the record (value either 0 or 1). There is a checkbox input on the page ( id="displayAll", checked value = 1).
I wanted to use the 'checked' property to ignore the filter (or, if it's easier, to uncheck the box to hide records with is active == 0)
I wanted to use the 'checked' property to ignore the filter (or, if it's easier, to uncheck the box to hide records with is active == 0)
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
What should happen on your page when the checkbox is checked and what when it is not checked?
* Checked = show only isActive == 1
* Unchecked = show only isActive == 0
Is that right?
* Checked = show only isActive == 1
* Unchecked = show only isActive == 0
Is that right?
Replied 7 years ago
7 years ago Lee Woolsey replied:
Checked no filter show all records ( isActive == 0 AND isActive == 1) unchecked show only isActive == 1.
Replied 7 years ago
7 years ago Lee Woolsey replied:
I could re-arrange it in another manner if that makes it easier to accomplish. The goal is to be able to hide records that are marked as inactive.
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
Lee i am not really sure i understand you. Your first post says one thing, your last one says another thing. Once again - what should happen when:
- Checkbox is not checked - which records should be displayed?
- Checkbox is checked - which records should be displayed?
- Checkbox is not checked - which records should be displayed?
- Checkbox is checked - which records should be displayed?
Replied 7 years ago
7 years ago Lee Woolsey replied:
If the box is not checked, display isActive == 1
If the box is checked, display isActive == 1 AND isActive == 0 (ALL records, i.e. NO filter)
If the box is checked, display isActive == 1 AND isActive == 0 (ALL records, i.e. NO filter)
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
I think this should work as a filter for your data view:
displayAll.checked.then(isActive , isActive == '1')
Replied 7 years ago
7 years ago Lee Woolsey replied:
No results are returned when I use that as a filter.
Oops, it did work perfectly. Thank you. (I had a typo in the filter definition!)
Is it possible to build that filter-string using the [lightning bolt] picker?
Oops, it did work perfectly. Thank you. (I had a typo in the filter definition!)
Is it possible to build that filter-string using the [lightning bolt] picker?
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
Can you send a link to your page please? Maybe the app connect data formatter includes are not on the page - try formatting something small just to get the includes on the page first.
Replied 7 years ago
7 years ago Lee Woolsey replied:
Thank you, it worked perfectly (once I corrected a typo). Is it possible to build that filter-string using the [lightningbolt] picker?
Replied 7 years ago
7 years ago Teodor Kuduschiev replied:
Yes, just use the "then" filter.
Replied 10 months ago
10 months ago Adarsh soni replied:
yes it is easy to do if you are from movies programming background