Jump to content

Recommended Posts

To hide particular columns (and column header) in tabular report page, add the following codes to the header and the footer

This goes in header:

<style>
#target table:nth-of-type(2) td:nth-of-type(3)  {display: none;}
#target table:nth-of-type(2) th:nth-of-type(3)  {display: none;}

#target table:nth-of-type(2) td:nth-of-type(4)  {display: none;}
#target table:nth-of-type(2) th:nth-of-type(4)  {display: none;}

#target table:nth-of-type(2) td:nth-of-type(5)  {display: none;}
#target table:nth-of-type(2) th:nth-of-type(5)  {display: none;}
</style>

<div id="target">

Add this to the footer:

</div>


The above style will hide columns 3,4 & 5. The number in table:nth-of-type(2)  depends on your result page design. If your result table is the first on the result page (case when you don't have download, or sort by dropdown or has a search form), this number should be 1. If you have download or sort by, or pre-defined criteria this number should be 2.

Number in td:nth-of-type(3) shows which column you want to hide. 1 refers to the first column, 2 second column and so on..

Also please note that this style is not supported by IE 8 and less. It should be fine on all other browsers.

Link to post
Share on other sites
  • 10 months later...
  • 1 year later...

May, your code is working and is taking away my style in the header bar. See the attached image. The last "RED SQUARE" Indicates the column to be hidden. It is working fine but taking away the blue background. How do I get the missing blue background to match the blue bar length to the gray bar below? The contents of the field (Shown as BLUE BOXES) is also not hiding

2018-03-14_17-25-54.png

Link to post
Share on other sites

Hi Rmohanr,

If you want to hide the text from the header bar, you can try this:

From MayMusic's answer, replace with:

#target table:nth-of-type(2) th:nth-of-type(3)  {
    /* Hide the text. */
    text-indent: 100%;
    white-space: nowrap;
    overflow: hidden;
}

or for sticky headers:

#target table:nth-of-type(2) th:nth-of-type(5)  {
    /* Hide the text. */
    text-indent: 100%;
    white-space: nowrap;
    overflow: hidden;
}

I hope this will help you.

Link to post
Share on other sites
  • 5 months later...

I have a table with 38000 records and when i group them and collapse it only shows the collapsed group for max 1000 records.

I don't actually need to see the records, only the group aggregate. Can I hide the result rows and only show the Group total line so I have a nice neat table showing all the group totals not expandable?.

 

Summary table.jpg

Link to post
Share on other sites
  • 1 year later...
  • 2 months later...

Just an update, for new version of Styles and when your DataPage's configuration is set to "enable responsive". Here's the new code:

Header: 
 

<style>
 
#target table:nth-of-type(1) td:nth-of-type(5)  {display: none;}
#target table:nth-of-type(1) th:nth-of-type(5)  {display: none;}

</style>
 
</header>
<div id="target">
<header>


Footer: 

</footer>
</div>
<footer>


Thank you @Vitalikssssss for this solution. 

For reference of new responsive feature, you could check it here: 
https://howto.caspio.com/datapages/responsive-datapages/prerequisites/
https://howto.caspio.com/release-notes/caspio-bridge-21-0/

Hope it helps!

Link to post
Share on other sites
  • 4 months later...

I have hidden 4 calculated fields with the below code for a responsive datapage. The columns are successfully hidden but I also have an aggregation to achieve a total.  In the screenshot below, the aggregation is no longer aligned with the column.   How can the code be modified to include the aggregation? 

Header

<style>
 
#target table:nth-of-type(1) td:nth-of-type(6)  {display: none;}
#target table:nth-of-type(1) th:nth-of-type(6)  {display: none;}
 
#target table:nth-of-type(1) td:nth-of-type(7)  {display: none;}
#target table:nth-of-type(1) th:nth-of-type(7)  {display: none;}
 
#target table:nth-of-type(1) td:nth-of-type(8)  {display: none;}
#target table:nth-of-type(1) th:nth-of-type(8)  {display: none;}
 
#target table:nth-of-type(1) td:nth-of-type(9)  {display: none;}
#target table:nth-of-type(1) th:nth-of-type(9)  {display: none;}

</style>
 
</header>
<div id="target">
<header>

Footer

</footer>
</div>
<footer>

hiddencolumns.PNG

Link to post
Share on other sites

Hello @rush360,

Please add this code to the Footer and test. It works on my end.

<script>
document.addEventListener('DataPageReady', changeColSpan);

  function changeColSpan() {
  var elem = document.querySelector('.cbResultSetTotalsLabelCell');
  var currentColSpan = elem.colSpan;
    
  elem.colSpan = currentColSpan - 4; // 4 is a number of hidden columns, you may change the value if needed

  document.removeEventListener('DataPageReady', changeColSpan);

}

</script>

Hope this helps!

Link to post
Share on other sites
  • 2 months later...

I found this code can work in the header to hide columns in tabular reports, but stops working for me if other text in the header is modified. Of course, the footer code is also needed.

<style>

#target table:nth-of-type(1) td:nth-of-type(2) {display: none;}
#target table:nth-of-type(1) th:nth-of-type(2) {display: none;}

#target table:nth-of-type(1) td:nth-of-type(4) {display: none;}
#target table:nth-of-type(1) th:nth-of-type(4) {display: none;}

</style>

</header>
<div id="target">
<header>

I think the order of our "coding" effects Caspio's code builder and found this procedure works to keep the above column hiding code working:

1) In Advanced tab, uncheck the HTML editor

2) In Standard tab, "cut" the above code from the header if it is already there

3) In Advanced tab, check the HTML editor

4) In Standard tab, do whatever changes you want to the text in the header

5) In Advanced tab, uncheck the HTML editor

6) In Standard tab, "paste" the above header code in the very top of the page

7) "Finish"

 

Link to post
Share on other sites
  • 1 month later...
  • 3 months later...
On 10/23/2020 at 12:43 AM, CoopperBackpack said:

Please add this code to the Footer and test. It works on my end.


<script>
document.addEventListener('DataPageReady', changeColSpan);

  function changeColSpan() {
  var elem = document.querySelector('.cbResultSetTotalsLabelCell');
  var currentColSpan = elem.colSpan;
    
  elem.colSpan = currentColSpan - 4; // 4 is a number of hidden columns, you may change the value if needed

  document.removeEventListener('DataPageReady', changeColSpan);

}

</script>

Hope this helps!

I wasn't able to get this to work for me. Unlike @rush360, my Totals column is aligned correctly, but I still have extra space to the right where I hid columns. Using the code above eliminates the extra space, but realigns the Totals number in the wrong column.

 hoursworked.JPG.3261b2aeae786765b47d94d89840a41e.JPG

Link to post
Share on other sites

Hello @kpcollier,

I suggested a solution for the Report that was provided in the screenshot. 

The JS solution should work if the Totals are for the field that is located after the hidden fields. 

Lets` say, you have 10 fields on the Result page, need to hide fields 5 and 6, and Totals are for field 9. In this case, Totals will not be aligned correctly and you may use the JS code to change the colspan value. 

May I know which fields are hidden and whether the Totals are for the last field in the Report as I can see from your screenshot? 

Link to post
Share on other sites

I'm not sure if this is a good solution, because by the naming of the class it seems it could affect not intended cells. But, a fairly simply CSS rule was able to get rid of the column.

Turns out it was just a couple extra cells in the Totals row itself. The columns were hidden, but those cells weren't.

.cbResultSetTotalsDataCell{
  display: none !important;
}

 

Link to post
Share on other sites

Hello @kpcollier,

I tested the same DataPage design in my account and you are correct, in your example we need to hide the 2 last cells in the row with the Totals.

In DevTools the layout has the following view: 

xiwYMvM.png

Basically, as I checked, the cbResultSetTotalsDataCell CSS class is used only for the Totals.

However, we can use a more complex selector to refer to the required cells.

tr[data-cb-name='grand_total'] td:nth-of-type(3),
tr[data-cb-name='grand_total'] td:nth-of-type(4) {display: none;}

 

Link to post
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
Reply to this topic...

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