YiiBoster Extended grid sum operation

273 Views Asked by At

I'm using the extend from Yiiboster (last version)

and I want to add a Total to an invoice and I want to do a TbSumOperation but without success so far

I don't know how to specify from which column on columns to sum

So far I only get a blank rectangle

I just copy pasted the example from the page and put it after columns=>(),

   'extendedSummary' => array(
        'title' => 'Total Employee Hours',
        'columns' => array(
            'hours' => array('label'=>'Total Hours', 'class'=>'TbSumOperation')
        )
    ),
    'extendedSummaryOptions' => array(
        'class' => 'well pull-right',
        'style' => 'width:300px'
    ),

Can anyone help?

1

There are 1 best solutions below

0
On

You have to look at this line from your init method

'dataProvider' => $gridDataProvider,

It is result what you do query and bind into grid, the column name which you would like to sum should be put in `extendedSummary.

Example: I want to sum working hours of my employees. My employee table has column hours like this

emp_id|name     |hours

1      Kevin     48    
2      Denton    16    
3      Harry     30

.

$gridDataProvider = new CActiveDataProvider('EmployeeModel', array(
                    'criteria' => array('condition' => 'age > 20')));

And I should have to put hours string into my grid summary setting