Jump to content
Alison

Hide the Edit button within Tabular Result page

Recommended Posts

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

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

@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>



 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×