Searching or filtering shadow assets


(Stephen Wardle) #1

Here I go again, posing the end of week brain teaser to all you dedicated Squiz peoples.


Ok, so I've created a data recordset from a a CSV file. dead easy…

I've then created an asset listing… also dead easy…



But, is that what I actually needed to do?



Here's my goal: I want to take a CSV file, this file has a couple of hundred records spanning a number of columns; name, suburb, phone, select class, select suburb. Each record has an individual name, phone, and suburb, but there are only a few select class, and select suburb records (options). On my webpage I want to display an initial set of results, based on the select class. I'd then like to be able to filter or display results depending on the other classes. I'd also like to filter by the select suburb column.



Keyword replacements are:

%data_source_record_set_suburb% Record Set Attribute : suburb

%ds__suburb% Record Set Attribute : suburb

%data_source_record_set_name% Record Set Attribute : name

%ds__name% Record Set Attribute : name

%data_source_record_set_phone% Record Set Attribute : phone

%ds__phone% Record Set Attribute : phone

%data_source_record_set_class_select% Record Set Attribute : class_select

%ds__class_select% Record Set Attribute : class_select

%data_source_record_set_suburb_select% Record Set Attribute : suburb_select

%ds__suburb_select% Record Set Attribute : suburb_select



Sample "Detail" of each shadow asset:

suburb A Suburb

name A business name p/l

phone (03) 9000 2222

class_select Class A

suburb_select Eastern suburbs



Is it even possible to search and filter shadow assets?



Cheers again guys.


(Edison Wang) #2

Unfortunately, shadow assets can not be searched or filtered.


I think you have to use javascript to handle this kind of sorting or searching.

One approach i can think so is like this:

The listing page is configured so it outputs a JSON array of data.

In a standard page, use JS to load the JSON array, and display the array content.

When user sets filter, search info, the JS will refresh the displayed content with filter.



Hope it helps.


(Stephen Wardle) #3

Oh, not what I was hoping to hear. So what can we do with data as an out of the box offering if we can't search or filter?


Thanks for tip on the JSON idea, I'll test that out and let you know how I go. Cheers


(Greg Sherwood) #4

[quote]
Oh, not what I was hoping to hear. So what can we do with data as an out of the box offering if we can't search or filter?

[/quote]



The CSV data source is typically used just for listings. You can format unfriendly records in a friendly way using asset listings. Then, updating the CSV file will update your listing. Someone people update the CSV file using a script in an automated way, so it helps there as well.



For searching and filtering of data, we would normally use the DB Data Source, where you can write your own DB queries and list them. People get creative in how they use the tools, building some fairly complex applications that add/edit/delete records and also provide search interfaces, but the barrier to entry is fairly high for those sort of systems. You need to have good knowledge of the DB Data Source and other tools within Matrix to get it going.



The JS idea is a good one if that will work for you as it doesn't sound like you need any editing capabilities at the moment.


Best way to filter Data Source Record Set by JSON output
(Stephen Wardle) #5

Absolutely right on the money. I found a really good JSON filter, so once I've hooked that up I'll post a link to the sample. Cheers


(Stephen Wardle) #6

Ok Squiz staffers, just thought I’d follow up and let you know what I did to solve my issue of needing to filter a CSV recordset.


I basically just used an out of the box google table chart (http://code.google.com/apis/ajax/playground/?type=visualization#table)



Firstly I created the CSV datasource.



The I created an asset listing to display my CSV data in the format needed for the google chart:

<br /> [&#39;%ds__name%&#39; , &#39;%ds__phone%&#39;, &#39;%ds__suburb%&#39;, &#39;%ds__class%&#39;, &#39;%ds__location%&#39;],<br />



Then in the body copy I wrapped the asset listing in the rest of the required google code:

<br /> // Prepare the data<br /> var data = google.visualization.arrayToDataTable([<br /> [&#39;Name&#39;, &#39;Phone&#39;, &#39;Suburb&#39;, &#39;Class&#39;, &#39;Location&#39;],<br /> %asset_listing%<br /> [&#39;&#39; , &#39;&#39;, &#39;&#39;, &#39;&#39;, &#39;&#39;]<br /> ])<br />



I added a couple of select controls (binded to make sure the choice of one effects the display of the other).



Outcome is here (page not finished yet): http://www.worksafe.vic.gov.au/safety-and-prevention/health-and-safety-topics/asbestos/asbestos-removalists2/


(Nic Hubbard) #7

[quote]
Outcome is here (page not finished yet): http://www.worksafe.vic.gov.au/safety-and-prevention/health-and-safety-topics/asbestos/asbestos-removalists2/

[/quote]



Awesome solution!