Hide fields during Master/Detail

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

Hide fields during Master/Detail

Post by konfuzion »

During normal view I'd like to show 10 fields
but during Master/Detail view, just show 3 fields of Master

Example:
/orderslist?showmaster=customers&fk_customer_id=1

I know can use $this->fieldname->Visible = FALSE; and put in pageload server event

But how to separate normal view and Master view? Is there a way to detect if normal view or master view?

If $isShowMaster then {
     $this->fieldname4->Visible = FALSE;
     $this->fieldname5->Visible = FALSE;
     $this->fieldname6->Visible = FALSE;
     $this->fieldname7->Visible = FALSE;
     $this->fieldname8->Visible = FALSE;
    $this->fieldname9->Visible = FALSE;
    $this->fieldname10->Visible = FALSE;
}

konfuzion
User
Posts: 378

Post by konfuzion »

actually can detect by URL, could just do something like this in Page_Load:

$isShowMaster = Get("showmaster");

if $isShowMaster <> "" {
     //insert hide code here
}

mobhar
User
Posts: 11660

Post by mobhar »

You may search in this forum by using getCurrentMasterTable keyword.


konfuzion
User
Posts: 378

Post by konfuzion »

In Server Events, I tried in Table_Orders / List Page / Page Load:

if ($this->getCurrentMasterTable() == "customers"){
    $this->customer_name->Visible = FALSE;
}

but doesn't work. I had to manually delete it from ../view/customersMaster.php

Maybe I put the code in the wrong place?


mobhar
User
Posts: 11660

Post by mobhar »

You should put it in Detail table instead of Master table.


konfuzion
User
Posts: 378

Post by konfuzion »

--MASTER/DETAIL WEB PAGE START--

[CUSTOMERS] MASTER VIEW

FIRSTNAME: Ben
LASTNAME: Cosby

[ORDERS] DETAIL LIST VIEW

ORDER#1 Order created on 2021/5/2
ORDER#2 Order created on 2021/8/14
ORDER#3 Order created on 2022/2/6

--WEB PAGE END--

In PHPMAKER Server Events:
[ORDERS] / List Page / Page Load

if ($this->getCurrentMasterTable() == "customers"){
    $this->customer_lastname->Visible = FALSE;
}

Not working... can still see LASTNAME


mobhar
User
Posts: 11660

Post by mobhar »

From your example above, the LASTNAME field is located at Master table, not in Detail table. That's why it won't work.


mobhar
User
Posts: 11660

Post by mobhar »

If you want to customize the Master section by hiding some fields and only show the others, then the closest approach is you may simply use Custom Templates -> Table-Specific -> Master Record Page -> CustomTemplate that belongs to the Master table.


konfuzion
User
Posts: 378

Post by konfuzion »

thumbsup working


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

I've master table: tbl_nks_dk_phieunhapxuatkho
and detail table: TblNksChitietphieunhapxuatkhoUpdatePhieunhapViewList
I want to hide the diengiai field in master table when i go to master/detail add:
..../TblNksChitietphieunhapxuatkhoUpdatePhieunhapViewList?showmaster=tbl_nks_dk_phieunhapxuatkho&fk_id=176

i added this code in Custom Template/Table Specific/Master Record Page/Custom Template of tbl_nks_dk_phieunhapxuatkho Table but it doesnt work.

if ($this->getCurrentMasterTable() == "tbl_nks_dk_phieunhapxuatkho")
{
    $this->setFailureMessage($this->diengiai->setVisibility());
    $this->lock->Visible = FALSE;
    $this->diengiai->Visible = FALSE;
    
}

arbei
User
Posts: 9286

Post by arbei »

vuongduongquoc wrote:

$this->setFailureMessage($this->diengiai->setVisibility());

Wrong code.


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

This code does't work.

if ($this->getCurrentMasterTable() == "tbl_nks_dk_phieunhapxuatkho")
{

    $this->diengiai->Visible = FALSE;
    
}

mobhar
User
Posts: 11660

Post by mobhar »

You should put that PHP code in Page_Load server event, and not in Custom Template/Table Specific/Master Record Page/Custom Template.

If you want to put your code in Custom Template section of Master Table, then you should refer to this documentation.


Post Reply