deemuss Posted January 5, 2022 Report Share Posted January 5, 2022 I have a tabular report and the link to the next page in the Footer. By default, the report is empty, and I want users to add one or several records. However, I do not want users to proceed without adding at least one record. I know that I should add JS if...else statement to the DataPage, however I have no idea on how to get the number of records there. I have attached my app if necessary. I would appreciate any assistance Tabular.zip Quote Link to comment Share on other sites More sharing options...
KlisaN137 Posted January 5, 2022 Report Share Posted January 5, 2022 Hi @deemuss You can use one of the following codes in the Footer of the DataPage: 1. With this one, link will still be on the screen, but it would not redirect anywhere: <a id='aLink' href="[@app:URL_1]">Caspio</a> <script> document.addEventListener('DataPageReady', function (event) { const link = document.querySelector('#aLink'); const message = document.querySelectorAll('.cbResultSetRecordMessage')[0]; if(message.textContent === 'No records found.') link.href = 'javascript:void(0)'; }); </script> 2. This one will remove link from the page: <a id='aLink' href="[@app:URL_1]">Caspio</a> <script> document.addEventListener('DataPageReady', function (event) { const link = document.querySelector('#aLink'); const message = document.querySelectorAll('.cbResultSetRecordMessage')[0]; if(link){ if(message.textContent === 'No records found.') link.remove(); } }); </script> Quote Link to comment Share on other sites More sharing options...
Alexray Posted January 5, 2022 Report Share Posted January 5, 2022 Hello. Here is one more way to do the same: <a id='aLink' href="[@app:URL_1]">Caspio</a> <script> document.addEventListener('DataPageReady', function (event) { if (document.querySelector('.cbResultSetDataRow[data-cb-name="data"]') == null) { document.querySelector('#aLink').style.display = 'none' } }); </script> Quote Link to comment Share on other sites More sharing options...
KlisaN137 Posted January 5, 2022 Report Share Posted January 5, 2022 @Alexray 'if' statement is better in your example, because the user could set a custom message when there is no records. But I would be careful using 'style.display', because the element is still the same and can be found using the console, and then easily 'hacked' into showing or clicking. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.