This topic is locked
[SOLVED]

 Hide Add Button

3/16/2021 6:33:42 PM
PHPRunner General questions
Tandy author

Hello all,I do not know if it can be done with out a lot of coding.I have my main table Trips. Then there are a good bit of detail tables under it. What I would like to know is can I set some kind of code to hide the ADD button on all the detail tables?

I can add this code:

if ($data["locked"] == "1"){

$pageObject->hideItem("add", $recordId);

$pageObject->hideItem("add");

$pageObject->hideItem("update_selected");

}

In the list page of each detail table, and it works great. But some detail tables do not have anything and I need to make it so they can not add if the lock is set to 1 on the master table (trips).

Thank you very much for any kind of help or pointing me in the right way of learning how this can be done..

James

A
acpan 3/16/2021

You can get the master table data via the built-in Page Class function getMasterRecord() on each detail tables.
Before or After Record Processed Event of detail tables:



// Get the master table data using

$master_data = $pageObject->getMasterRecord();

$master_locked = $master_data["locked"];
if ($master_locked == "1"){

$pageObject->hideItem("add", $recordId);

$pageObject->hideItem("add");

$pageObject->hideItem("update_selected");

}
Tandy author 3/17/2021

Thank you for the Help acpan.
I got it to work by putting the below code in all the Details tables under List page - before display.



// Get the master table data

$master_data = $pageObject->getMasterRecord();

$master_locked = $master_data["locked"];

// Use master table to lock the details table

if ($master_locked == "1"){

$pageObject->hideItem("add", $recordId);

$pageObject->hideItem("add");

$pageObject->hideItem("delete", $recordId);

$pageObject->hideItem("delete");

$pageObject->hideItem("update_selected");

$pageObject->hideItem("update_selected", $recordId);

}

//END Lock


Then I already have the isEditable in place so it can not be edited..

Thanks again for your help..

James