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