Jump to content
  • 0

hiding a column in a report datapage based on a parameter


VA123

Question

Depending on what location is associated with a user(a column in the user table - the parameter), I would like to selectively hide a specific column in a report datapage. I am able to get Caspio to hide the column as desired on the preview Caspio page , but when deployed, Caspio seems to ALWAYS hide the column, regardless of the Country condition. Could you please take a look? This is where the datapage is deployed: https://dsmtest001.weebly.com/testjsreport.html. There are 2 user accounts-> 
1. user1@test.com | 12341234 - Country is USA
2. user2@test.com | 12341234 - Country is Canada
Column B should be hidden for the USA user but not the Canadian user. 
The selective functionality is achieved through the following code, inserted in the header of the report datapage:
<script>
alert('[@authfield:Country]' +' is the current country ' + ' -> going to hide column/row B if country is USA');
if ('[@authfield:Country]' === 'USA') {
document.getElementById('targetxxx').innerHTML = "<style>#targetxxx table:nth-of-type(1) td:nth-of-type(2) {display: none;} </style>";
document.getElementById('targetxxx').innerHTML = "<style>#targetxxx table:nth-of-type(1) th:nth-of-type(2) {display: none;} </style>";
}
</script>

<div id="targetxxx">
and the below inserted in the footer:
</div>

Last but not least, attached is the sample Caspio app

CaspioData_2019-Feb-25_2157.zip

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hi

I hope you could help me with my issue. I'm trying to hide tabular report columns based on the search criteria,  I have a search page with few different search criteria, at the moment once you select your search criteria and hit search it passes parameters to the tabular report page and it outputs data to  a tabular report.  but it displays all of the columns in the report page, What Iwant to do is to hide columns that are not related to the selected search, Is this something possible. I am on the basic Caspio plan.

Would love to hear ideas, fixes from anyone

Many Thanks

 

Link to comment
Share on other sites

  • 0

@Vindy

I have checked your tables.
I think that using JS in your case will be very inefficient. The code will be huge, slow and unmanageable.
You should try to change the table structure to make it more normalized.

Check these articles to get familiar with normalization of tables:
https://howto.caspio.com/tables-and-views/relationships/
https://en.wikipedia.org/wiki/Database_normalization

 

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...