How to hide add and delete button in master Detail table

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
apis
User
Posts: 124

How to hide add and delete button in master Detail table

Post by apis »

i have hid master table edit button with th following code:
function ListOptions_Rendered() {
if ($this->Status->CurrentValue == "Saved") {
$this->ListOptions->Items["edit"]->Body = "False";
}

In my master table i have a radio button, "Draft" and "Saved". if the user select "Saved", i want to hide master detail table delete and edit button.

please help.


mobhar
User
Posts: 11660

Post by mobhar »

Change this code:
$this->ListOptions->Items["edit"]->Body = "False";

to:
$this->ListOptions->Items["edit"]->Body = "";


apis
User
Posts: 124

Post by apis »

Mobhar,
Thank you for you reply.
$this->ListOptions->Items["edit"]->Body = "";
sorry it doesnt work for all buttons.

I have a master table and a detail table. In the master table there is a radio button "Draft" or "Saved"
What i want to do is HIDE "edit" and "Addlink" in the MasterDetail table "when the user selects "Saved" in the master table.


kirondedshem
User
Posts: 642

Post by kirondedshem »

$this->ListOptions->Items["edit"]->Body = "False";
THis should be
$this->ListOptions->Items["edit"]->Visible = FALSE;
or
$this->ListOptions->Items["edit"]->Body = "";
to hide edit button in detail isthe same as in any other table. YOu ca get the master id of a detail record at this point as well
function ListOptions_Rendered() {
if ($this->Status->CurrentValue == "Saved") {
//get master id of curent record by using its master_id field of the table
$master_id = $this->master_id->CurrentValue;
//Put condition ased on $master_id
$this->ListOptions->Items["edit"]->Visible = FALSE;
}

To hide an add button from the list age,preview page or list apge of master detail edit page try any of the following
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";
//remove default add button from detail list page or preview page
$this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;

//remove add blank row link during masterdetail edit
$this->OtherOptions["addedit"]->Items["addblankrow"]->Visible = FALSE;

}


arbei
User
Posts: 9284

Post by arbei »

apis wrote:
I have a master table and a detail table. In the master table there is a
radio button "Draft" or "Saved"
What i want to do is HIDE "edit" and "Addlink" in the
MasterDetail table "when the user selects "Saved" in the
master table.

If you need to hide the link/button when the user the radio button, you need to add your code in [Edit Tag] -> [client side events] to hide/show the detail table's div.

For example:
<?php if ($this->getCurrentDetailTable() <> "") {?>
if (<condition>) {
$(".ewDetailPages").hide();
}
<?php } ?>


bkay
User
Posts: 101

Post by bkay »

To hide an add button from the list age,preview page or list apge of master detail edit page try any of the following
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";
//remove default add button from detail list page or preview page
$this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;

//remove add blank row link during masterdetail edit
$this->OtherOptions["addedit"]->Items["addblankrow"]->Visible = FALSE;

I've tried the above EXACTLY as shown, and seems to make no difference.

Using F12, the class of the button is -
'btn btn-default ew-add-edit ew-add-blank-row' or
'a.btn.btn-default.ew-add-edit.ew-add-blank-row'
(Depending on whether I hover over it with the picker, or look at the code in the side window)

And there are 2 of them, one at the top of the detail, and another at the bottom, both with the same class.

Any other suggestions, or things to try?

Thank you,
Bill


bobmulder5555
User
Posts: 60

Post by bobmulder5555 »

kirondedshem wrote:
To hide an add button from the list age,preview page or list apge of master detail
edit page try any of the following
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";
//remove default add button from detail list page or preview page
$this->OtherOptions["addedit"]->Items["add"]->Visible =
FALSE;

//remove add blank row link during masterdetail edit

$this->OtherOptions["addedit"]->Items["addblankrow"]->Visible

= FALSE;

}
FYI, I just tried (2018)
//remove default add button from detail list page or preview page
$this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;

and it works brilliantly in the listview page


Post Reply