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…

  • Not yet re-checked
  • Classic builder

Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

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”

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”

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.

Text
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”
Screenshot for “How to Hide Component Based on “No Records” in Table”

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

Was this page helpful?

Something wrong or missing on this page? Tell us.