# Hide table column if empty

**URL:** <https://forum.wixstudio.com/t/hide-table-column-if-empty/51333>\
**Category:** Ask the community\
**Tags:** code\
**Created:** [August 9, 2023, 8:51am UTC](https://forum.wixstudio.com/t/hide-table-column-if-empty/51333 "2023-08-09T08:51:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.wixstudio.com/u/user87)\
**Post date:** [August 9, 2023, 8:51am UTC](https://forum.wixstudio.com/t/hide-table-column-if-empty/51333/1 "2023-08-09T08:51:32Z")

</div>

Hi, I’m trying to hide a table column if it is empty. I have a large database of products for which all technical specs are not relevant.  
Here for example I need to hide several blank columns. Can anyone help? I have no experience with coding. thanks

 ![image](https://us1.discourse-cdn.com/wix/original/3X/f/e/fea3b23b1ee8dfe6ba0ca9da61414a2e6fc5eed1.png)

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 14, 2023, 1:51pm UTC](https://forum.wixstudio.com/t/hide-table-column-if-empty/51333/2 "2023-08-14T13:51:06Z")

</div>

```javascript
$w.onReady(() => {
 $w('#dataset').onReady(() => {
  const rows = $w('#table').rows;
  const columns = $w('#table').columns;
  if(rows.length){
   colomns.forEach(col => {
    const rowsWithCellValue= rows.filter(row => row[col.dataPath]);
    col.visible = !!rowsWithCellValue.length;
   })
  $w('#table').columns = columns;
  }
 })
})

```

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.wixstudio.com/u/user87)\
**Post date:** [August 21, 2023, 8:02am UTC](https://forum.wixstudio.com/t/hide-table-column-if-empty/51333/3 "2023-08-21T08:02:33Z")

</div>

Hi J.D, thanks for the help. Unfortunately this does not seem to work. I did change the values to my #dataset2 and #table1. Is there anything else I need to change?

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.wixstudio.com/u/user87)\
**Post date:** [August 21, 2023, 11:34am UTC](https://forum.wixstudio.com/t/hide-table-column-if-empty/51333/4 "2023-08-21T11:34:41Z")

</div>

oups forgot a parenthesis, it works perfectly!  
Thanks soooo much!!!
