ParkLoey Posted August 22, 2022 Report Share Posted August 22, 2022 Hi everyone, I was wondering if it is possible to hide the bulk edit option in a tabular page depending on the currently logged in user. For example, if the user logged in is an "employee", the option to bulk edit is hidden. If they are an "admin", it is shown. I can't seem to find any option to do this in Caspio but maybe some of you has experience with it. Thanks!! Quote Link to comment Share on other sites More sharing options...
futurist Posted August 23, 2022 Report Share Posted August 23, 2022 Hi @ParkLoey, You can use the following JavaScript on the Footer of your DataPage: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if("[@authfield:Role]" == "Employee"){ var elems= document.querySelectorAll(".cbResultSetCheckBoxCell"); [].forEach.call(elems, function(elem, i) { elem.remove(); }); var checkboxheader = document.querySelector(".cbResultSetHeaderCheckBoxCell") var bulkedit = document.querySelector("[id*='PageActionsCtnr']") checkboxheader.remove(); bulkedit.remove(); } }); </script> make sure to change the Role in [@authfield:Role] with your actual role field, and Employee with the role type you want to hide the Bulk Edit option for. Quote Link to comment Share on other sites More sharing options...
Meekeee Posted August 26, 2022 Report Share Posted August 26, 2022 Hi @ParkLoey - you can also use this script in the Footer of the DataPage: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if("[@authfield:Role]" == "Employee"){ document.querySelector("nav[class*='cbActionPanel']").style.display='none'; // Hide Edit button let label = document.querySelector('table[data-cb-name="cbTable"] th:nth-of-type(1)'); // Select the label of first column for checkboxes let values = document.querySelectorAll('table[data-cb-name="cbTable"] td:nth-of-type(1)'); // Select all the values in the first column for checkboxes /* Removing the selected fields */ label.parentElement.removeChild(label) values.forEach(el => { el.parentElement.removeChild(el) }); } }); </script> You can check these forum posts for reference: Quote Link to comment Share on other sites More sharing options...
futurist Posted August 30, 2022 Report Share Posted August 30, 2022 Hi @ParkLoey, if you have the data grouping enabled but still want to hide the checkboxes conditionally based on user role, you can use the following: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if("[@authfield:Role]" == "Employee"){ var elems= document.querySelectorAll("input[type='checkbox']"); [].forEach.call(elems, function(elem, i) { elem.style.display = "none" }); var checkboxheader = document.querySelector(".cbResultSetHeaderCheckBoxCell") var bulkedit = document.querySelector("[id*='PageActionsCtnr']") bulkedit.style.display = "none" } }); </script> Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted September 27, 2022 Report Share Posted September 27, 2022 Hi @futurist and @Meekeee These are great solutions--thanks for posting! Meekeee 1 Quote Link to comment Share on other sites More sharing options...
futurist Posted June 20 Report Share Posted June 20 Hi, sharing this bulk edit feature I came up with that you might find useful: 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.