expo101
Posts: 24
|
Posted: 02/29/2012, 11:57 PM |
|
Hi,
Have a Checkboxlist in a Form with the label values dynamically generated from a SQL query. The label values show in the text the number of records linked to the checkbox option, i.e. "Roundtrips (5)". When no records, the value is 0 and the checkbox should be hidden.
Tried to achieve this with the Before Show in the Checkbox List Events tab, using the action Hide-Show component but sofar unsuccesfull, it's not clear to me how to put the settings. Based on a certain checkboxlist label value, the checkbox should not be shown.
Your suggestions are welcome!
|
|
|
clahti2
Posts: 107
|
Posted: 03/01/2012, 12:15 PM |
|
so if I understand you correctly, you have two controls, a label that displays the total, and a checkbox. How are you getting the record count for the label? Are you are using something like $myRecordForm->DataSource->num_rows, or are you doing a DLookup to get the count? Either way the checkbox Before Show event is the correct place to do this, you may have to place the checkbox in a panel control and hide/show the panel.
|
|
|
expo101
Posts: 24
|
Posted: 03/01/2012, 11:38 PM |
|
Hi clahti2,
Thanks for your reaction on my topic.
The label I'm referring to is actually the {Description} of the checkbox as you can see in this html code:
<!-- BEGIN CheckBoxList d8 --><input id="i_search_2_newdatad8_{d8:optionNumber}" name="{d8_Name}" value="{Value}" type="checkbox" {Check} /><label for="i_search_2_newdatad8_{d8:optionNumber}">{Description}</label><br /> <!-- END CheckBoxList d8 -->
And this SQL statement defines the value of the checkboxlist {Description}:
select CONCAT ("Rondreis (", count(DISTINCT reisorg_id,reiscode_org,reisduur),")") AS omschrijving, "rondreis" AS reissoort from t_masterselectie WHERE reisduur BETWEEN '{rm1}' AND '{rm2}' AND CASE WHEN '{vv}'<>"" THEN vertrekdatum BETWEEN '{vv}' AND DATE_ADD('{vv}',INTERVAL '{vt}' DAY) ELSE vertrekdatum BETWEEN CURDATE() AND DATE_ADD(CURDATE(),INTERVAL 1000 DAY) END AND landen LIKE '%{b}%' AND rondreis=1 AND CASE WHEN '{d1}'='riviercruise' THEN riviercruise=1 ELSE rondreis=1 END AND CASE WHEN '{d2}'='zeecruise' THEN zeecruise=1 ELSE rondreis=1 END AND CASE WHEN '{d}'='Single' THEN singlereis=1 ELSE rondreis=1 END AND CASE WHEN '{d4}'='familiereis' THEN familiereis=1 ELSE rondreis=1 END AND CASE WHEN '{d5}'='wandelen' THEN wandelen=1 ELSE rondreis=1 END AND CASE WHEN '{d6}'='fietsen' THEN fietsen=1 ELSE rondreis=1 END AND CASE WHEN '{d7}'='langlaufen' THEN langlaufen=1 ELSE rondreis=1 END AND CASE WHEN '{d9}'='standplaatsreis' THEN standplaatsreis=1 ELSE rondreis=1 END AND CASE WHEN '{v1}'='bus' THEN bus=1 ELSE rondreis=1 END AND CASE WHEN '{v2}'='vliegtuig' THEN vliegtuig=1 ELSE rondreis=1 END AND CASE WHEN '{v3}'='boot' THEN boot=1 ELSE rondreis=1 END AND CASE WHEN '{v4}'='trein' THEN trein=1 ELSE rondreis=1 END AND CASE WHEN '{v5}'='eigen gelegenheid' THEN eigen=1 ELSE rondreis=1 END
You can see it all running in the left column of this website: http://www.engroupe.nl
The only challenge I still have is to hide the checkbox and {Description} where (0) is in the {description}. I need some more guidance on how to achieve this in the Before Show event. Any suggestions are welcome!
|
|
|
clahti2
Posts: 107
|
Posted: 03/03/2012, 2:49 PM |
|
That is quite an SQL statement you have there If you are using MySQL I would move this to a view personally. At any rate if you want to suppress showing the checkbox and it's description why not add to the WHERE clause such as
AND omschrijving NOT LIKE %0%
You might also add a field in the select clause
count(*) from somefield AS count and then add WHERE count > 0.
From what I can tell you are using these checkbox fields to filter articles in the main section, but if there are no articles of a particular category you do not want the checkbox to appear, correct?
|
|
|
expo101
Posts: 24
|
Posted: 03/05/2012, 4:13 AM |
|
Thanks for your reply clahti2. Doing the utmost on the SQL The statement runs actually from a table which was created from a view. think you are right that I have to look into the sql statement again. Indeed when there are no articles, the checkbox should not appear.
|
|
|
ReneS
Posts: 225
|
Posted: 03/05/2012, 10:17 AM |
|
Not really helping...but... your sql statement is a Wereldreis
|
|
|
expo101
Posts: 24
|
Posted: 03/08/2012, 1:03 PM |
|
Put this jquery script in the form and it worked
$('label:contains("(0)")').each(function() { $('#' + $(this).attr('for')).hide(); $(this).hide(); });
Now reached 'eindbestemming' ! See result on http://www.engroupe.nl
|
|
|
|