Urgent: Issue with cascading dropdown where value is concatenated

Status
Not open for further replies.

jeanl

Member
Hi

I have a table with element that is concatenated from "start year" and "end year", by means of a calculation element.

I am trying to use this element as options in a cascading dropdown, but values are not available. Can someone please help?

See attached.
 

Attachments

  • Here are the elements.pdf
    116 KB · Views: 162
Did you set your calc element to "Only calc on save"=yes?

If it's set to NO then the list display is calculating on the fly, so showing the concat string.

But this string will only be stored in the database when editing/saving your record, i.e. you must re-save any existing record or fill the calc column via a cron php task or directly with phpMyAdmin.

Can't you use the "Concat label" of CCD element?
 
I'd go with Troester's suggestion, and seeing if you can achieve what you need by using the CONCAT label on a CDD, so you are doing the concat at CDD query time, self contained within the CDD itself.

-- hugh
 
Hello and thanks.

Can you pls tell me how to do this:
"Can't you use the "Concat label" of CCD element?"
 
I can see where the concat info must be inserted, but what would the string look like if the two elements are called:
start_year
end_year
and the table they are in is called harness_selector
see image attached
 

Attachments

  • concat.png
    concat.png
    12.7 KB · Views: 145
OK, your original PDF seemed to be missing the image of the actual calc element itself, so I'm not sure how you want that formatted. But assuming you wanted "start_year - end_year", it'd be:

{thistable}.start_year, ' - ', {thistable}end_year

Leave {thistable} exactly as-is, don't change ti to the name of your table. The reason being, if you ever join the same table more than once, it'll have an "alias" like yourtable_0, yourtable_1, which you won't know ahead of time. So {thistable} gets replaced by us, with whatever alias we are using for your table at that point.

-- hugh
 
Hello Hugh and thank you for your reply.

I am not sure if I followed you, but when I used your suggested string, I got this, but just so you know, the elements used is not in "thistable" but in another....

getData:Unknown column 'harness_selector_1.start_year' in 'field list' SQL=SELECT SQL_CALC_FOUND_ROWS DISTINCT `harness_guide`.`id` AS `harness_guide___id`, `harness_guide`.`id` AS `harness_guide___id_raw`, `harness_guide`.`date_time` AS `harness_guide___date_time`, `harness_guide`.`date_time` AS `harness_guide___date_time_raw`, `harness_guide`.`make` AS `harness_guide___make_raw`, `harness_selector`.`vehicle_make` AS `harness_guide___make`, `harness_guide`.`model` AS `harness_guide___model_raw`, `harness_selector_0`.`vehicle_model` AS `harness_guide___model`, `harness_guide`.`year_range` AS `harness_guide___year_range_raw`, CONCAT(harness_selector_1.start_year, ' - ', harness_selector_1end_year) AS `harness_guide___year_range`, `harness_guide`.`id` AS slug , `harness_guide`.`id` AS `__pk_val` FROM `harness_guide` LEFT JOIN `harness_selector` AS `harness_selector` ON `harness_selector`.`vehicle_make` = `harness_guide`.`make` LEFT JOIN `harness_selector` AS `harness_selector_0` ON `harness_selector_0`.`vehicle_model` = `harness_guide`.`model` LEFT JOIN `harness_selector` AS `harness_selector_1` ON `harness_selector_1`.`id` = `harness_guide`.`year_range` LIMIT 0, 10

So, I started from the beginning, to explain what it is I need, and I attach this with screenshots in the doc attached.

Please can you help me, I am really in a bit of a pickle.
 

Attachments

  • fab concat.pdf
    162.1 KB · Views: 146
Looking at your first pdf the column names are start_date, end_date (not x_year), and there's a . missing in Hugh's string.
So try
{thistable}.start_date, ' - ', {thistable}.end_date
 
Can I concat three elements, and if so, how would this string change?
{thistable}.start_date, ' - ', {thistable}.end_date
 
You can use any column (element) of your database table with {thistable}.column-name and any string you like 'abcd' e.g.
'From: ',{thistable}.start_date, ' to: ', {thistable}.end_date,' Event: ',{thistable}.eventname
 
Status
Not open for further replies.

Members online

No members online now.
Back
Top