Hide columns in detail table only when exporting (v2023)

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

Hide columns in detail table only when exporting (v2023)

Post by philmills »

I need to hide some columns in my detail table when exporting (pdf and print).
Alternatively if there's a way to remove links in the detail table when exporting that would also be OK.
I tried using this in Page_Load of the Preview page and List page of the detail table:

    if (IsExport("pdf")){
        $this->myField->Exportable = false; 
    } 

but it doesn't seem to do anything...


mobhar
User
Posts: 11908

Post by mobhar »

Simply change Exportable to Visible, and try again.


philmills
User
Posts: 581

Post by philmills »

Tried that, it didn't work
I have this in List page

public function pageLoad()
    {
        //Log("Page Load");
    if (IsExport("pdf") || IsExport("print")){
        $this->fk_IncidentID->Visible = false;
        $this->Filename->Visible = false;    
    }		
    }

philmills
User
Posts: 581

Post by philmills »

Strange - I added this to Page_Load of the generated Grid page and the fields are now correctly hidden from print export, but they are still there in pdf export...


mobhar
User
Posts: 11908

Post by mobhar »

For Export to PDF, you should use isExport() method that belongs to the current page, instead of IsExport() global function.

So, your code should be:

public function pageLoad()
{
    //Log("Page Load");
    if ($this->isExport("pdf") || IsExport("print")){
        $this->fk_IncidentID->Visible = false;
        $this->Filename->Visible = false;    
    }		
}

philmills
User
Posts: 581

Post by philmills »

I need to apply this to a new a new master/detail scenario
I'm exporting from master View with Detail table showing below.
I need to hide some fields in the detail table only from pdf export.

I tried adding it to Grid, Preview and List Page_Load event, and none of them work

	if ($this->isExport("pdf")){
        $this->fk_StudyPlanID->Visible = false;
        $this->id->Visible = false; 
	$this->fk_School->Visible = false; 
	$this->Added->Visible = false;
        $this->Updated->Visible = false;
	}	

v2023


sangnandar
User
Posts: 1053

Post by sangnandar »

I'm exporting from master View with Detail table showing below.

If you're in master View, the context of $this is the master table, hence $this->(detail table field) is non-existent.
You can try access detail table fields using $GLOBALS, e.g. $GLOBALS["detail table field"]


philmills
User
Posts: 581

Post by philmills »

I'm not sure what you mean exactly.
If the master table has multiple detail tables, both tables have an "Added" and "Updated" fields, so surely i need to access both the detail table name and the field name.
what's the syntax for that?


sangnandar
User
Posts: 1053

Post by sangnandar »

Sorry, $GLOBALS["detail table field"] should be $GLOBALS["detail table"]->(fieldname)
If you have multiple detail tables, it would be
$GLOBALS["detail table one"]
$GLOBALS["detail table two"]
$GLOBALS["detail table etc"]


Post Reply