Jump to content
  • 0

I need help with rules or conditions in a gallery report.


DavidwDavis

Question

8 answers to this question

Recommended Posts

  • 0

Hello @DavidwDavis,

It seems, that the result can be achieved with JavaScript.

Please try to follow these steps:

1. Go to the Search and Report Wizard - Configure Results Page Fields page, add Header and Footer.

In the Header add CSS style that hides the image. Do not forget to disable HTML editor on the Advanced tab before pasting the code.

<style>
.u__display-none {
 display: none;
}
</style>

2. Do not add the Checkbox field and Image field to your Results page. Instead of this add the HTML block (disable HTML editor) and paste the following code into it:

<img class="image-elem" src="[@field:Image/]"></img>
<p class="checkbox-elem">[@field:Checkbox_field]</p>

In this way we add fields` values as parameters. Replace the field names with your local names. 

3. Paste this snippet of code in the Footer section (disable HTML editor before pasting).

<script type="text/javascript">
document.addEventListener('DataPageReady', hideImagesHandler);

function hideImagesHandler() {

var flagArr = document.querySelectorAll('.checkbox-elem');
var imagesArr = document.querySelectorAll('.image-elem');

flagArr.forEach(function(elem, i) {
   if(elem.innerText === 'No') {
   imagesArr[i].classList.add('u__display-none');
  }
 })
};
</script>

This code adds display:none property for the image if the Checkbox field is not checked. 

Hope this helps.

Feel free to update this thread if you have any questions or comments.

 

Link to comment
Share on other sites

  • 0

@DavidwDavis,

I am glad to hear that solution works for you.

We can add style="display:none;" to the paragraph tag to hide Yes/No values.

Also, we can add the width to the image.

Therefore, the changes should be done only  in the HTML  block.

This is the updated code:

<img class="image-elem" src="[@field:Image/]" width="120"></img>
<p class="checkbox-elem" style="display:none;">[@field:Checkbox_field]</p>

Please test it and let me know in case you have other concerns.

 

Link to comment
Share on other sites

  • 0

@DavidwDavis,

You are welcome. 

1) When you select the View, but not the Table to build the DataPage, this solution should work as well.

You are correct, this is the question of correct field names. 

For your convenience, please use a Picker icon to select the correct field, because in the View the syntax for the field name is following: Table_Name_Field_Name

image.png.703747468d1aa9420dd58adb0cad52d0.png

Add Image as a File URL and Checkbox as a String.

2) Here is the example of the workaround of using Files in the Triggered Action.

 

 

 

Link to comment
Share on other sites

  • 0

CoopperBackpack,

This is working and is awesome! Here is what I need to adjust.

The words "Yes" and "No" show up in the results. If the checkbox is not checked then the word "No" shows up in the results. If the checkbox is checked then the image appears and the word "Yes" shows up. How do I get rid of these words?

Thanks for all the help.

David Davis

Link to comment
Share on other sites

  • 0

This is working perfect. Thanks! You are awesome.

I have two more questions.

  • Will this process work on joined tables, as in the image is in one table and the checkbox is in another table. I'm going to experiment with this, just wondering if it makes sense. I'm thinking you just need to use the table/field names in place of the field names.
  • On the topic of triggered actions. Caspio does not support assigning a file field by a triggered action. Do you know of any work-arounds?

Thanks again,

David

Link to comment
Share on other sites

  • 0
On 10/15/2020 at 9:03 AM, DavidwDavis said:

I have a basic table with records that includes a file field (image) and a status field (checkbox). I need to do a gallery report where the image only shows when the status field is checked. Is there a way to do this?

Thanks for the help.

David Davis

Generally, you can filter your records via this configuration: image.thumb.png.8d1bb561b56bc0574287574881380460.png

 

 

Learn more about how it here: https://howto.caspio.com/datapages/reports/creating-a-report-datapage/ 

 

You can also still configure even if the Report has a search function. However, the field with the status that you wanted should be set to hidden and has a default value to work. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...