Server Action Folder List : Paging, Sort and Search

I have an SPA page that looks at a file directory and returns a list of files using a Server Action Folder List. This works well, but there are thousands of files.

image

This list isn’t created as part of a Paged Query so how can I do Paging, Sort and Search on this list, the same as I can with my other Queried pages?

Also, I can see folders inside this directory but how do I see files in those sub-folders?

image

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

I do this using a server connect action to get the list of files and then use the Data View component in App Connect - so I can using paging etc. This may not be practical with a very large number of files, but I’ve used it with over 10,000 files and it takes less than 2 seconds to display the page; after that searching/soriting etc is more or less instant.

Alternatively, you could create an image database table - creating records as images are imported. A potential issue with this is if images can be uploaded via FTP for example, bypassing your database inserts. To get round this, you can create a facility to rebuild the image table. Again, this is pretty quick. I’ve just tried it on my folder with 10k images and it took less than 10 seconds (on my hosting site - it’s slower on the Windows computer in front of me).

&$(@$£#@ &^$£|?!!!
I’m using Data View and it never crossed my mind that I have the functionality at my finger tips!
Thanks for the guidance (and proverbial slap on the hand :laughing:)

How do you get on with sub-folders? By that I mean, how do you display them and their contents?

I haven’t actually used this option, but it’s a promising looking option:

image

Yeah, I’ve got that selected, the folder shows by name only and nothing within.

image

Does this look right to you?
Not working yet so not sure where I’m going wrong.

You have to use a repeat on the folder list

Hi Marcel, do you mean use a repeat on the folder list to view the sub-folders? If so I had thought it might be something like that but I have not tried it as yet.

Can you do a screenshot of a sample setup?

Yes, that’s how I did it:

I have to mention, that I didn’t use the output because I use the Server Action for a db insert.

OK, great that helps. Thanks.

Won’t this only work if you subfolder names are known in advance? It should be possible to get the subfolder names and contents dynamically, but I haven’t quite managed it yet. This gets all the files, in the main folder and in subfolders one level down, but I’m not sure how to put it into a table at the other end:

image

… where the second folder list is:

image

(the path of each subfolder)

I think this Data View setup looks alright. I had some extra values for a filter etc.:

image

No, if you look at my third screenshot you see that i get the dynamic path from the first folder list.

I just noticed, having looked more carefully! Great.

@MH2ag @TomD @Teodor
Hi guys, I am nearly there with this file directory thing. The list of files displays correctly (not looked at sub-folders yet) and the sorting and paging also works correctly.

The one part I cannot seem to get to work is the search / filter. There are no conditions to filter by as you do with a query. Can you help?

Do these screenshots look right?

image

Also, I am not sure if this is a bug or something I am doing wrong, but when I select
Dynamic Picker in the Data View > Data View Properties > Filter and Sort On
there is nothing available

image

To search on the file name, I used this for the filter:

image
(‘searchfield’ being the name of the input field)

Simply brilliant and brilliantly simple! (when you know how :laughing:)
That’s great BUT I needed to change things slightly for my own case.
I wanted to search anywhere in the file name and so I substituted “startsWith” with “contains”. Then I found that it was case sensitive so I converted everything to lowercase, and here is my final filter…

filter="name.lowercase().contains(filter_reports_msword.value.lowercase())"

It seems to work :smile:

EDIT
I’ve just taken it one stage further and removed spaces as well, this means that if a file has a registration number in it such as NR16 GBY with a single space then when the user searches, it won’t matter if they put
NR16GBY
NR 16 GBY
N R16GBY
it will still find the file.

filter="name.lowercase().replace(' ', '').contains(filter_reports_msword.value.lowercase().replace(' ', ''))"

I hope this helps others.