Dynamic change of List Header / Caption / Column name

I’ve got a view with a database that has the following fields:Salesperson, Month1, Month2, Month3, etc…

I’m trying to dynamically change the displayed column name to:Salesperson, Jan-2019, Feb-2019, Mar-2019, etc.

I’ve found several similar posts on the forum and tried them all, and couldn’t get them to work. setFldCaption() doesn’t appear to be a supported function anymore.

I can however loop through the field and pick out the field names.

However, I’m not able to change the column name in the rendering. I’ve pasted this code just about everywhere… ListOptions_Load, Page_Render, Page_Load.

I think I’m very close, but not quite there. Any suggestions would be appreciated.

foreach($this->fields as $fld){
//$fld->setFldCaption($fld->FldCaption() . “”); (causes error)
echo($fld->Name.‘</ br>’);
if ($fld->Name == ‘Month2’) {
echo(‘*’);
$fld->Name = “Asdf”;
}
}

You may use setCaption(). (v2020)

Thank you,setCaption() works great.

Here’s my code under Page_DataRendering under the List Page section:

This converts COL1, COL2, Month1, Month2, Month3, etc…
to COL1, COL2, 2020-01, 2020-02, 2020-03, etc.

$heading_date = date(“Y-m-d”);
foreach($this->fields as $fld){
if (substr($fld->Name, 0, 5) == ‘Month’) {
$fld->setCaption(substr($heading_date, 0, 7));
$heading_date = date(“Y-m-d”, strtotime(“+1 month”, strtotime($heading_date)));
}
}Now I’m working on doing the same for the Excel export.

Thanks,
Bob