Visible Master/Detail View, Edit and Copy buttons

want to ask,
how to make visible false the master/detail edit, view and copy buttons in PHPMaker 2024.2.I put it in page render:$this->OtherOptions[“addedit”]->Items[“edit”]->Visible = FALSE;Doesn’t work,
help me, I’m a beginnerThankyou

You may use ListOptions_Rendering server event.

When I tried this code, the error Attempt to assign property “DetailAdd” on null appeared

$orderdetailsGrid = Container("orders_itemsGrid");
$orderdetailsGrid->DetailAdd = false; // Set to true or false conditionally
$orderdetailsGrid->DetailEdit = false; // Set to true or false conditionally
$orderdetailsGrid->DetailView = false;

Rachman wrote:

the error Attempt to assign property “DetailAdd” on null appeared
$orderdetailsGrid = Container(“orders_itemsGrid”);

The error means $orderdetailsGrid is null, and “orders_itemsGrid” is wrong class name. You should check your table variable name, read Database, Table and Field Variable Names.If your table name is “orders_items”, then the class name of the detail grid page should be “OrdersItemsGrid”, you may refer to the file name of the generated script.

yes I have changed it as you suggested but it doesn’t work
$orderdetailsGrid = Container(“OrdersItemsGrid”);please help me solve this problem

If you don’t need to hide them by code, you may simply use the table settings, i.e. Master/Detail XXX (as Detail), for List page.If you want to hide them by code, make sure you have placed your code in the ListOptions_Rendering server event of master table.As suggested you should check the detail grid class name by comparing the file name of the class. (Do not just and paste examples, you need to modify them to suit the table names of your own project.)

Learn how to debug and learn how to use var_dump() to check your variables.

thank you, it worked.but when I try to hide the add detail button,
I log in as a user and can’t add detailed master data, but if I log in as admin I can add detailed master data?
this is the code:
table details - listpage - page render :

$vall = ExecuteScalar("SELECT status FROM request WHERE id_req='".$this->id_req->CurrentValue."'");
     if (!IsAdmin()){
         if ($this->id_req->CurrentValue == $vall) {
             $this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;
            
         }
     }

What if logging in as a user could add detailed master data without having to set user level permissions and check admin?

If you have enabled User Level Security, you should check the user’s permissions. The user needs to have “Add” permission for both the master and detail tables for using Master/Detail-Add.

I have checked add, edit the user level permissions for master details. but I can’t add add master detail if I hide the button if logged in as the default userI tried removing the add button in the view page (add button above the list) if the status is approved,

Be reminded that there is no $this->id_req->CurrentValue in Add page, data is not inputted yet.

and now I tried the following code to hide the add button in the view, it worked, but I added new data and the error xxxItemGrid.php(2586) appeared: Attempt to assign property “Visible” on nullhere’s the code

function Page_Render()
{
    //Log("Page Render");
    if ($this->getCurrentMasterTable() <> "" || CurrentPageID() == 'view' || CurrentPageID() == 'list') {
	    $this->OtherOptions['addedit']->Items['add']->Visible = FALSE;
    }
}
  1. Page_Render server event is per page, so there is no need to check CurrentPageID(),
  2. The error means $this->OtherOptions[‘addedit’]->Items[‘add’] is null. Note that there is no need to set up those options on insert/update, so you should check if it is not null before using it, e.g. (v2024)
$this->OtherOptions->getItem('addedit')?->getItem('add')?->setVisible(false);

Read Nullsafe operator.

Hi all, (PHP 2024) I success to hide the ADD Button follow above info , put the code in ListOptions_Rendered() , as follows:

 $MTDetNo = $this->MT_NO->CurrentValue;
 $MTState = ExecuteScalar ("SELECT MT_STATE FROM MTHEADER WHERE MT_NO = '".$MTDetNo."'");

if($MTState=="P" || $MTState=="D"){
    $this->ListOptions->Items["edit"]->Body="";
    $this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;

My Question is how to hide/disable INLINE-ADD button ? Please Help. Thanks in advanced

You better view what the list options contain first, e.g. var_dump($this->ListOptions).

THANK YOU !!! after var_dump,

var_dump($this->OtherOptions[“addedit”]);I can see the button ‘name’.I add this line :$this->OtherOptions[“addedit”]->Items[“inlineadd”]->Visible = FALSE;And the result is CORRECT (Hide inlineadd button in my detail table)