Jump to content

Dynamically Hide Empty Columns in Tabular Report

Recommended Posts

I have a tabular report that has 30 columns. Some users only use 10, 12, 15, etc. of the columns, whereas others use all 30. Has anyone come across a good way to dynamically hide the columns that have no data for that user? Or even better, for that particular search/filter? 

One additional caveat, I would like the DataPage to be downloadable, so if possible I would like to try to avoid something that uses hidden calculated fields in the columns, because then when downloaded, those columns would be downloaded as well. 

Thank you in advance for any help or ideas. Please let me know if any additional information is needed!

Link to comment
Share on other sites

@cheonsa Those sections don't seem to be working for me. I did figure out a temporary workaround using JavaScript, but it doesn't seem like the optimal way to handle cases. I added a field to my Authentication table that specifies the number of columns the table needs to have. Then I reference it in the footer with this code. This doesn't handle cases where I search and a smaller subset is returned, but it does at least handle cases where all columns are blank for that user all the time. Any additional ideas on how I might be able to better handle these cases?

document.addEventListener('DataPageReady', function (event) {
  let table = document.querySelector('table[data-cb-name="cbTable"]');
  if (table) {
    while (table.querySelector('tr').children.length >= [@authfield:Hide_Ref]) {
      let label = table.querySelector('th:nth-of-type([@authfield:Hide_Ref])');
      let values = table.querySelectorAll('td:nth-of-type([@authfield:Hide_Ref])');
      if (label) label.parentElement.removeChild(label);
      values.forEach(el => {
        if (el) el.parentElement.removeChild(el);

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.

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.

  • Create New...