Hi guys, how can I have a repeat expression that matches, say, these three options.
My data is from a Server Action Folder List which could contain 20 or 30 or more files.
Here is my expression but only finds one of the three files… <div dmx-repeat:repeat9="sc_ad_job_q.data.repeat_folderList.where(name, '_AD_Report.pdf', 'contains')">
I want to return the three specific files that end in… '_AD_Report.pdf', '_AD_Fee_Note.pdf', '_AD_Base_Report.pdf'
I can’t set an ‘IN’ within a query because it is a ‘FolderList’
I don’t know how to set a ‘Contains’ with more than one option.
I can’t seem to do a [1,2,3].contains(2) type of scenario.
I know I could set a ‘SHOW’ or ‘HIDE’ but that doesn’t give me a fixed list to manipulate.
Hi @mebeingken, it’s probably closer but I don’t think I was very clear. The ['_AD_Report.pdf', '_AD_Fee_Note.pdf', '_AD_Base_Report.pdf']
parts are ends of the file names so needs to be some sort of EndsWith as well.
Or is there such a thing as a wildcard? ie [anything]_AD_Report.pdf
Now I’m starting to think regex but I am very week on that subject.
Have done this type of filtering using custom formatter before. Don’t remember where so can’t share sample code, but the idea is that the custom formatter will filter data as you want.
Will see if I can find and share it. I think @Apple also has shared something along these lines in community before.
I’m not sure of the answer on the client side, but my rule of thumb is if it gets too complex on the client side then you should be doing something different on the server side…
… so could you write a more specific server action or create a database view to give you an output to repeat which just has the files you want?
I often create a database field to categorise things… so if these three files all relate to category X of file then I’ll add a “category” column to a database table of “files_descriptions” and then just do a .where on column “category” having a value of X.
Hi @Antony, you are quite right, often we try to make things more complicated than they need to be and there is often a simpler way. I have done a bit of playing around, work in the Server Action and work at the client end. The result works but is not ideal.
One thing that came to mind was that once I have used the Server Action ‘Folder List’, I should then (somehow?) manipulate that list within the Server Action to get exactly what I want.
‘Folder List’ simply gets the full list of files, say 35 files.
That then gives me an ‘Array’ which I should be able to work with but I can’t seem to do what I want. Wappler is powerful enough but I just can’t work out how to do it.
If you are on NodeJS, RunJS is the fastest solution to all random data JS based manipulations, that are not worth the hassle of creating custom modules/formatters.
For PHP, you can build modules/formatters to do things beyond Wappler’s built-in steps.
Hi @sid, thanks for that. It is PHP in this instance and I have never attempted to build any modules/formatters so a scary option for me. It’s probably straight forward but just never attempted it