HTML5 Data Bindings Support Product Page

Answered

Conditional region

Asked 20 Sep 2013 13:02:44
1
has this question
20 Sep 2013 13:02:44 Andre Bender posted:
I set up a Repeat Region with some divs that should only be shown if the recorset field new = 1. How do I achieve this?

Replies

Replied 20 Sep 2013 13:12:44
20 Sep 2013 13:12:44 Teodor Kuduschiev replied:
Hello,

Are you using this with the DMXzone Database Connector?
Replied 20 Sep 2013 13:14:10
20 Sep 2013 13:14:10 Andre Bender replied:
yes
Replied 20 Sep 2013 13:16:08
20 Sep 2013 13:16:08 Teodor Kuduschiev replied:
Can you please describe a little more detailed your idea - if you can also provide a link it will be better.
Replied 20 Sep 2013 13:21:21
20 Sep 2013 13:21:21 Andre Bender replied:
I want to show my records with a repeat region. In the database table some of the records have a field new with the value 1 some with the value 0. For all the records with the field new = 1 I'd like to show a dedicated div, but not for the records with the field values new = 0.

Just a simple conditional statement like this one

<?php if ("".$row_rsRecordset['New'] ."" == "1" { ?>
<div class="ribbon-wrapper"> </div>
<?php } ?>
Replied 20 Sep 2013 14:07:20
20 Sep 2013 14:07:20 Teodor Kuduschiev replied:
You can achieve this using the data.show attribute.
Select the div that you want to show if = 1 , select the column named "New", open the Bind to menu and select div.data.show, then click the Bind button.
Replied 20 Sep 2013 14:16:02
20 Sep 2013 14:16:02 Andre Bender replied:
When I click on the "New" colum I can only select Text, Image or iFrame and Insert it. There is no Bind Menu ...
Replied 20 Sep 2013 14:20:27
20 Sep 2013 14:20:27 Teodor Kuduschiev replied:
Ah, sorry, please wrap your div with an empty <span> and try again.
Replied 20 Sep 2013 14:27:08
20 Sep 2013 14:27:08 Andre Bender replied:
ok now I have
<span data-binding-show="{{KundeNeu}}"><div class="ribbon-wrapper">
<div class="ribbon-red"></div>
</div></span>
But where do I set the condition "value = 1"?
Replied 20 Sep 2013 14:31:29
20 Sep 2013 14:31:29 Teodor Kuduschiev replied:
The data-binding-show attribute checks if the KundeNeu column has value or is empty. If it is empty the <span> with the content inside will be hidden. If there is a value in the field, the span will be shown.
Replied 20 Sep 2013 14:32:02
20 Sep 2013 14:32:02 Andre Bender replied:
Sorry, it worked. The test recoord was just hidden because there was a show only 25 records per page limit.
But anyway, what do I do if I have to set the condition on a specific value like 2 out of a data range of for example 1,2,3,4,5?
Replied 20 Sep 2013 14:34:28
20 Sep 2013 14:34:28 Teodor Kuduschiev replied:
I will discuss your idea with the developers and we will include such options in the future updates.
Replied 20 Sep 2013 14:37:29
20 Sep 2013 14:37:29 Andre Bender replied:
That would be great. Thanks Teodor
Replied 23 Feb 2016 20:38:21
23 Feb 2016 20:38:21 Hans Haverlach replied:
Is there any progress on this matter? Just run into the same problem/question. It would be great to not only have the boolean comparrison!
Thanx.

Hans
Replied 23 Feb 2016 21:09:05
23 Feb 2016 21:09:05 Teodor Kuduschiev replied:
Hello Hans,
lots have changed in the extensions, since the last post in this topic.
Can you describe what do you want to achieve?
Replied 23 Feb 2016 21:28:59
23 Feb 2016 21:28:59 Hans Haverlach replied:
Yes, i'll try.
I use the repeat function to show a datagrid.
Each row shows some data and a picture.
Now, I only want to show the picture if the source is in the database.
Something like:
<img data-binding-class-imgnotexist="{{inst_imagetmb != ''}}" src="../../../..{{inst_imagetmb}}" alt="Instrumentfoto" width="30%" /> (with the class name I would show/hide the image)

I know I can use the data-binding-show attr. for this, but I tried this because it often happen also that I want something like this:

<div data-binding-class-hideme="{{inst_serieid != 'somevalue'}}">content</div> OR
<div data-binding-class-hideme="{{inst_serieid > 4}}">content</div>

I hope you understand my purpose of the show/hide functions?
Is this already possible? I think I am not correct with the code: {{inst_serieid != 'somevalue'}} but have no clue how to make this comparison.
Hope to hear from you!
This reply was removed on 2/23/2016 9:29:14 PM.
See the changelog
Replied 29 Feb 2016 22:37:48
29 Feb 2016 22:37:48 Hans Haverlach replied:
Yes, i'll try.
I use the repeat function to show a datagrid.
Each row shows some data and a picture.
Now, I only want to show the picture if the source is in the database.
Something like:
<img data-binding-class-imgnotexist="{{inst_imagetmb != ''}}" src="../../../..{{inst_imagetmb}}" alt="Instrumentfoto" width="30%" /> (with the class name I would show/hide the image)

I know I can use the data-binding-show attr. for this, but I tried this because it often happen also that I want something like this:

<div data-binding-class-hideme="{{inst_serieid != 'somevalue'}}">content</div> OR
<div data-binding-class-hideme="{{inst_serieid > 4}}">content</div>

I hope you understand my purpose of the show/hide functions?
Is this already possible? I think I am not correct with the code: {{inst_serieid != 'somevalue'}} but have no clue how to make this comparison.
Hope to hear from you!
Replied 24 Feb 2017 12:54:51
24 Feb 2017 12:54:51 Reinhardt Ellis replied:
any help on this.....

FROM....

<?php if ("".$row_rsRecordset['New'] ."" == "1" { ?>
<div class="ribbon-wrapper"> </div>
<?php } ?>

To this.... BUT WITH A VALUE????

<div data-binding-show="{{New}}"></div>

with a value... eg???

<div data-binding-show="{{New}} > 1"></div>
Replied 24 Feb 2017 13:06:48
24 Feb 2017 13:06:48 Teodor Kuduschiev replied:
Hello Reinhardt,
adding conditions is as easy as:

<div data-binding-show="{{New == 1}}"></div>
OR
<div data-binding-show="{{New > 1}}"></div>
<div data-binding-show="{{New >= 1}}"></div>

Replied 24 Feb 2017 13:18:00
24 Feb 2017 13:18:00 Reinhardt Ellis replied:
And the solution for the following would be?
I would normally use a PHP IF statement to show the <OPTION></OPTION> or not ..
because the DIV tag wont hide the <OPTION></OPTION> inside a <SELECT>

The OLD way

<select name="items" id="items">

<?php if ($item == 0) { ?>
<option value="ITEM" <?php if ($item == 0) { ?>disable<?php } ?>>ITEM - NO ITEMS AVAILABLE</option>
 <?php } ?>

<?php if ($item > 0) { ?>
<option value="ITEM">ITEM - ITEMS AVAILABLE</option>
 <?php } ?>

</select>




Please could you provide a solution

<select name="items" id="items">

<div data-binding-show="{{ITEM == 0}}">                                           
<option value="ITEM" >ITEM - NO ITEMS AVAILABLE</option>
</div>

<div data-binding-show="{{ITEM > 0}}">                                           
<option value="ITEM" >ITEM - ITEMS AVAILABLE</option>
</div>  

</select>  



I have even tried this... it echos the values.. but not selecting it correct inside the <option> tags


<?php
$black = "{{stock.data.query1[0].Black}}";
?>

<select name="colour" id="colour">
<option value="Black" <?php if ($black == 0) { ?>disable<?php } ?>>Black</option> 
</select


So it echos the $black correctly... so if you <?php echo $black ?> it give you a value say 1 or 0.
But as soon as I <?php if ($black == 0) { ?>TEST<?php } ?> then no luck...

Replied 24 Feb 2017 13:23:21
24 Feb 2017 13:23:21 Teodor Kuduschiev replied:
Try applying it on the option:

<option value="ITEM" data-binding-show="{{ITEM == 0}}">ITEM - NO ITEMS AVAILABLE</option>
Replied 24 Feb 2017 13:30:09
24 Feb 2017 13:30:09 Reinhardt Ellis replied:
Thank you for the reply.. let me try that.. ...

OK THAT WORKED... thank you for the reply.. sometimes one overthinks things .. when its just a simple change in code... over worked..not focusing.. just frustrated sometimes ... and need help... so appreciate the help...

Reply to this topic