# How to Hide Component Based on “No Records” in Table

> Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add…

Source: https://tadabase.com/docs/snippets/how-to-hide-component-based-on-no-records-in-table  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

> **Warning:** Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins [here](https://tadabase.com/docs).

This snippet will teach you how to hide a component when a table doesn’t have any records showing.

![Screenshot for “How to Hide Component Based on “No Records” in Table”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663104027831.png)

The solution provided is through custom JS code:

**Step 1**

**Find the Component ID of the table you'd like to hide when it doesn't contain any records.**

![Screenshot for “How to Hide Component Based on “No Records” in Table”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663104197778.png)

**Step 2**

**Add the following JavaScript to the JavaScript tab on the parent page (the page that contains the form), not the details page. Replace component_xx with your component number.**

```
TB.render(‘component_XX’, function(data) {
if (data.records === undefined || data.records.length === 0) {
data.ele.css(‘display’,‘none’)
}
});
```

![Screenshot for “How to Hide Component Based on “No Records” in Table”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663104267821.png)

![Screenshot for “How to Hide Component Based on “No Records” in Table”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663104320764.png)

Please note that this does not work if the table is filtered.

**Original Community Post:**

[https://community.tadabase.io/t/hide-component-based-on-no-records-in-table/2120](https://community.tadabase.io/t/hide-component-based-on-no-records-in-table/2120)
