DMXzone App Connect Data Traversal Support Product Page

Answered

Apply a filter (or not) if a checkbox is checked

Asked 18 Dec 2017 16:45:51
1
has this question
18 Dec 2017 16:45:51 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 19 Dec 2017 07:28:18
19 Dec 2017 07:28:18 Teodor Kuduschiev replied:
Hi Lee,
Is the "isActive" the filter itself or would you like to use it in order to trigger another filter?
Replied 19 Dec 2017 14:10:43
19 Dec 2017 14:10:43 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)
Replied 19 Dec 2017 14:18:59
19 Dec 2017 14:18:59 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?
Replied 19 Dec 2017 15:10:37
19 Dec 2017 15:10:37 Lee Woolsey replied:
Checked no filter show all records ( isActive == 0 AND isActive == 1) unchecked show only isActive == 1.
Replied 19 Dec 2017 15:12:53
19 Dec 2017 15:12:53 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 19 Dec 2017 15:31:58
19 Dec 2017 15:31:58 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?
Replied 19 Dec 2017 15:39:04
19 Dec 2017 15:39:04 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)
Replied 19 Dec 2017 16:23:41
19 Dec 2017 16:23:41 Teodor Kuduschiev replied:
I think this should work as a filter for your data view:


displayAll.checked.then(isActive , isActive == '1')

Replied 19 Dec 2017 16:40:19
19 Dec 2017 16:40:19 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?
Replied 19 Dec 2017 16:40:54
19 Dec 2017 16:40:54 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 19 Dec 2017 17:03:13
19 Dec 2017 17:03:13 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?
This reply was removed on 12/19/2017 5:36:21 PM.
See the changelog
Replied 20 Dec 2017 08:52:51
20 Dec 2017 08:52:51 Teodor Kuduschiev replied:
Yes, just use the "then" filter.

Reply to this topic