ATK4 - addTotals() results in 0.00 for totals

2019-09-17 09:47发布

I am working with ATK4.2.1 and trying to get the addTotals() functionality to work on my Grid. I have tried setting the data to the grid with both the setModel and setSource methods. My grid shows up correctly with all data showing and with what appears to be the addTotals() row, but the results are always 0.00 on any fields I try setting as the 'money' type.

Method #1-

class page_showStats extends Page {
    function init(){
    parent::init();

        $grid=$this->add('Grid');
        $grid->setModel('aggrStats');
        $grid->addTotals();

    }
}

class Model_aggrStats extends Model_Table {
    public $table='aggrReports';
    function init(){
        parent::init();
        $this->addField('date')->type('date');
        $sitename = $this->join('websites','websiteID');
        $sitename->addField('sitename','name')->caption('Client');
        $sitetype = $this->join('adTypes','typeID');
        $sitetype->addField('typename','name')->caption('Product');
        $siteorigin = $this->join('origins','originID');
        $siteorigin->addField('originname','name')->caption('Origin');
        $this->addField('impressionsTotal')->Caption('Imp Opps')->sortable(true);
        $this->addField('impressionsFilled')->caption('Imps Filled')->sortable(true);
        $this->addField('fillPercent')->sortable(true)->caption('Fill %');
        $this->addField('grossRevenue')->type('money')->sortable(true);
        $this->addField('grossCPM')->sortable(true);
        $this->addField('netRevenue')->type('money')->sortable(true);
        $this->addField('netCPM')->sortable(true);
    }   
} 

Method #2 -

class page_slicer extends Page {
    function init(){
    parent::init();

        $g=$this->add('Grid');
        $g->addColumn('date','date');
        $g->addColumn('text','impressionsTotal');
        $g->addColumn('text','impressionsFilled');
        $g->addColumn('text','fillPercent');
        $g->addColumn('text','grossRevenue');
        $g->addColumn('text','grossCPM');
        $g->addColumn('money','netRevenue');
        $g->addColumn('text','netCPM');

        $g->setSource('aggrReports');

        $g->addTotals();

    }
}

Both methods generate the grid with the empty totals row (the second method doesn't include some identifying pieces that the first method does because I was focused on just attempting to get a money column to sum.)

!Grid with zero-sum totals1

Any thoughts on what I could be missing? Thanks.

标签: atk4
0条回答
登录 后发表回答