i have added a custom column in CGridView named Balance and calculate current balance by using this now i want to add current balance in footer like below :
i m using code :
class BalanceColumn extends CGridColumn {
private $_total = 0;
public function renderDataCellContent($row, $data) { // $row number is ignored
$_minus = array('Returned','Expense');
if(in_array($data->idIncomeType0->Name, $_minus) || in_array($data->idIncomeType0->Category, $_minus))
$this->_total-=$data->Amount;
else
$this->_total += $data->Amount;
echo $this->_total;
}
public function renderFooterCellContent(){
echo '28';
}
}
?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'payments-grid',
'dataProvider'=>$cdataProvider,
'columns'=>array(
.....,
array(
'header' => 'Balance',
'class' => 'BalanceColumn',
'footer' => '',
),
..... ),
));
Right now i just echo the value , how could i get the last balance from renderDataCellContent? m i following the right way ?