Alison Posted December 5, 2018 Report Share Posted December 5, 2018 How can I hide the Edit button within Tabular Result page? Quote Link to comment Share on other sites More sharing options...
Andrii Posted December 5, 2018 Report Share Posted December 5, 2018 Hello Alison, I will add the application to let you play with it. You can implement this functionality using JavaScript. First of all, you need to copy a value of a needed field in the HTML block adjust it as the <p> HTML element with class and hide it. To copy the value use the parameters feature. Then you need to insert the following code in the footer: <script type="text/javascript"> document.addEventListener('DataPageReady', function () { var vals = document.getElementsByClassName("your_class_name"); var buttons = document.getElementsByClassName("cbResultSetActionCell"); for (var i=0; i < vals.length; i++){ if (vals[i].innerHTML == your_value){ buttons[i].style.display = "none"; } } }); </script> You need to copy the class value of your <p> element in the "your_class_name" part and adjust the value of "your_value" part according to your conditions. CaspioData_2018-Dec-05_1425 (1).zip Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 5, 2018 Report Share Posted December 5, 2018 If you do not enable inline edit you will not have Edit button on the report page. If you want to see the button conditionally you can, add HTML Block and add a javascript to show a link to a separate details page to edit a row. Quote Link to comment Share on other sites More sharing options...
Andrii Posted December 6, 2018 Report Share Posted December 6, 2018 @MayMusic If you want to hide just Edit button and leave the details button, use this code: <script type="text/javascript"> document.addEventListener('DataPageReady', function () { var values = document.getElementsByClassName("your_class_name"); var editButtons = document.getElementsByClassName("cbResultSetActionsLinks"); var firstButton = 2; var secondButton = 3; for (i = 0; i < values.length; i++) { if(values[i].innerHTML == your_condition) { editButtons[firstButton].style.display = "none"; editButtons[secondButton].style.display = "none"; } firstButton += 4; secondButton += 4; } }); </script> It is also adjustable if you have delete button: <script type="text/javascript"> document.addEventListener('DataPageReady', function () { var values = document.getElementsByClassName("your_class_name"); var editButtons = document.getElementsByClassName("cbResultSetActionsLinks"); var firstButton = 2; var secondButton = 3; for (i = 0; i < values.length; i++) { if(values[i].innerHTML == your_condition) { editButtons[firstButton].style.display = "none"; editButtons[secondButton].style.display = "none"; } firstButton += 6; secondButton += 6; } }); </script> Quote Link to comment Share on other sites More sharing options...
Carlson Posted December 31, 2018 Report Share Posted December 31, 2018 MayMusic, Is it possible to hide the delete button of inline insert, based on the value of authentication field? EdwardG 1 Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted January 2, 2019 Report Share Posted January 2, 2019 Hey Carlson, Your question is a bit off-topic to this thread, but the answer to your question is yes, you may. If you wanted to "hide" the Delete button in general (NOT record-specific), you may paste>modify this code on your Footer with HTML Editor disabled in the Advanced tab: <script> var condition = ("[@authfield:role]" != "admin"); //Your condition /*Edits are not necessary from this point onward */ var deleteButtons = document.querySelectorAll('[data-cb-name="InlineDelete"]'); if(condition) { deleteButtons.forEach(function (elem) { elem.style.display = "none"; }); } </script> ==== A per-record implementation is a bit more complex, paste the following code snippets in their respective places with HTML Editor disabled. The only modification needed is the "condition" Header <script> var toHide = []; function hideDelete(idx, cond) { if (cond) toHide.push((idx-1)*2); } </script> HTML Block <script> var condition = ("[@field:created_by]" == "[@authfield:userid]"); hideDelete([@cbRecordIndex], condition); </script> Footer <script> var deleteButtons = document.querySelectorAll('[data-cb-name="InlineDelete"]'); toHide.forEach(function(elem) { deleteButtons[elem].style.display = "none"; deleteButtons[elem+1].style.display = "none"; }) </script> I hope this helps. If you have questions, I'd suggest to start another forum thread then mention me in there to keep this thread clean. Happy new year! Cheers, DN31337 EdwardG 1 Quote Link to comment Share on other sites More sharing options...
RonAnderson Posted January 6 Report Share Posted January 6 Hi @DefinitelyNot31337, I came across this code which looks like it could provide a solution for me. I have a Tabular Report Results page in which I have a custom "Copy" button next to the standard "View Details" and "Delete" buttons. I want to hide the "Copy" button if the condition "PAT" shows in the "In_Scope" field. I copied and reconfigured your code by changing all cases of "Delete" to "Copy". Here's the amended code:- HEADER:- <script> var toHide = []; function hideCopy(idx, cond) { if (cond) toHide.push((idx-1)*2); } </script> HTML BLOCK:- <script> var condition = ("[@field:In_Scope]" == "PAT"); hideCopy([@cbRecordIndex], condition); </script> FOOTER:- <script> var copyButtons = document.querySelectorAll('[data-cb-name="InlineCopy"]'); toHide.forEach(function(elem) { copyButtons[elem].style.display = "none"; copyButtons[elem+1].style.display = "none"; }) </script> I have used your code in the case of the "Delete" button because in different circumstances I need to hide the "Delete" button and it works perfectly but unfortunately it doesn't work for the "Copy" button. I've tried to make this work for 2 days now and still no luck. Is there anything you can suggest that I've overlooked? I'd be deeply grateful for any help you can give. Kind regards Ron Anderson Quote Link to comment Share on other sites More sharing options...
Ilyrian Posted April 26 Report Share Posted April 26 There is also a HowTo article regarding this question.https://howto.caspio.com/tech-tips-and-articles/disabling-inline-edit-option-in-reports-based-on-a-condition/ You can modify the code to work for Details and Delete 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.