Filtering a Data View

How can I filter on more than one field when using Data View?

I have to filter on the Data View (and NOT the Server Connect) because I am viewing a Folder List and not a Database Query.

Here is my Data View

<dmx-data-view id="view_msword_files" dmx-bind:data="sc_reports_msword_pq.data.msword_reports_list" dmx-bind:sorton="query1.data.sort" dmx-bind:sortdir="query1.data.dir" dmx-bind:page="query1.data.page" dmx-bind:pagesize="15" filter="name.lowercase().replace(' ', '').contains(filter_reports_msword.value.lowercase().replace(' ', ''))"></dmx-data-view>

And a screenshot of a portion of the Data View result

Currently my filter filters on the ‘name’ field, but I also want to filter on the ‘size’ and ‘created’ fields as well.

I have tried

<dmx-data-view ... filter="condition1;condition2;condition3"></dmx-data-view>
<dmx-data-view ... filter="condition1 && condition2 && condition3"></dmx-data-view>

but neither of these seem to work.

As an example, I am trying to find all files that

  • name CONTAINS “Qdos”
  • size GREATER THAN “400000”
  • created AFTER “13/07/2020”

Can anyone advise?

Current set-up : SPA Pages, Windows 10, MySQL, PHP

You should be able to use Data Bindings panel to get a cond1 && cond2 type argument. Problem is that my panel remains empty, niks, nada. @George may be able to throw light on the problem.

Morning Ben, yes mine is also blank.

I seem to have cracked it with a little bit of playing around and experimenting.

PLEASE NOTE: at the time of this post the dynamic picker was not showing any options and so this was hand-coded.

image

All these checkboxes are within a form group

<div class="form-group row" id="input1_group" is="dmx-checkbox-group">

so I had to ensure that the ‘ID’ of the form group “input1_group” was included when referencing the checkbox. And I was able to separate conditions by “&&”.

<dmx-data-view ... filter="
	(name.lowercase().replace(' ', '').contains(filter_reports_msword.value.lowercase().replace(' ', ''))) 
	&& (input1_group.filter_pdf.checked ? extension.contains('pdf') : extension.contains('') ) 
	&& (input1_group.filter_doc.checked ? extension.contains('doc') : extension.contains('') ) 
	&& (input1_group.filter_1mb_plus.checked ? size > 1024000 : size > 0 )
	&& (input1_group.filter_last_28_days.checked ? modified > DateAndTimeInDays.datetime.addDays(-28) : modified )
"></dmx-data-view>

The one thing that doesn’t work is when both “PDF files” and “Word files” are checked I get a blank result. Can anyone suggest what I can do to get this to work? I would like it to show both PDF and Word files.

image

I hope this helps others.

Your filter only includes && conditions and not || conditions so you are not handling the OR condition for pdf and doc files to appear when both are selected.
A file can’t be a pdf and a doc at the same time ergo you are not getting results.

Hi Jon, most of the files are paired as PDF and DOCX files so you do get plenty of pairs like this
abc123.pdf
abc123.docx
These are the main file types, but there are the odd files with a different file extension such as
.doc (and .docx) which are both covered by “extension.contains('doc')
.png, .jpg and .svg - graphic files
.txt, .xml, .xls, .xslx - document files

So the common filter combinations required are
All files
All PDF files
All Word files (.doc and .docx)
All PDF and Word files together

I agree that there is a way of doing it but I can’t get my head around it. I’ll keep trying :smile:

What I mean is that the same file can’t be a pdf and a docx at the same time. It is either one or the other. And you are evaluating if an item in your list is a pdf and a doc at the same time.

Edit: or not. I don’t have my laptop so I can’t check.

Cheers Jon, I did understand. My long-winded reply was to help me as much as anything.

I have got is working with the following. It may be a long way round but it works.

( !input1_group.filter_pdf.checked && !input1_group.filter_doc.checked ? extension.contains('') : 
( input1_group.filter_pdf.checked && !input1_group.filter_doc.checked ? extension.contains('pdf') : 
( input1_group.filter_pdf.checked && input1_group.filter_doc.checked ? ( extension.contains('pdf') || extension.contains('doc') ) : 
( !input1_group.filter_pdf.checked && input1_group.filter_doc.checked ? extension.contains('doc') : 'Error' ))))

I also did this to show myself that I had 4 combinations to put into a nested ternary operation. I did it by hand as I find the picker too complex for something like this

filter_pdf.checked	n	y	y	n		
filter_doc.checked	n	n	y	y