Cgridview Get Summery Of Checked Row Values

Hi all,

I am using cgridview with ccheckboxcolumn to select the invoices for processing. I want to display the total amount of checked invoices before they processed. Can any one help me to do this ?

So far I tried with this post but failed because ccheckboxcolumn not support to the event ‘onChange’ !

hi,anilherath .u can use checkBoxList ,event ‘onClick’ can help .

Dear Life_free,

Thank you for the quick response. I tried as you proposed but failed ( I have less experience in Yii).

Actually What I did so far is create the cgridview with ‘CCheckBoxColumn’;

$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'banking-grid',

    'selectableRows' => 2, // multiple rows can be selected

    'dataProvider' => $model->searchUpdate(),

    'filter' => $model,

    'columns' => array(


            'class' => 'CCheckBoxColumn',


            'value'=> '$data->id',





            'name' => 'banking',

            'value' => '($data->banking == 1) ? Yii::t(\'app\', \'Yes\') : Yii::t(\'app\', \'No\')',

            'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),






            'filter' => GxHtml::listDataEx(Customer::model()->findAllAttributes(null, true)),





I want to display the Total ‘amount’ of checked rows before submit.

Dear AnilHerath

Kindly check whether the following is helpful to you.

I presume that you need the total of all values in a column in checked rows.

Register the following script in admin.php

Also create a textField to collect the total value.


id of CGridView:test-grid

checkbox column is the 6th column in my grid.

I want to calculate the the total values of 3rd column.



$("body").on("change","#test-grid input[type=\"checkbox\"]",function(){

var checked=$("#test-grid input[name=\"test-grid_c5[]\"]:checked");

var value=0;



	var row=$(j).parent().siblings();




return false;



echo CHtml::textField('Total','',array('id'=>'total','placeholder'=>'Get the total'));


var checked=$("#test-grid input[name=\"test-grid_c5[]\"]:checked");

Here number 5 indicates checkbox is in 6th column of the grid.


Here number 2 indicates that we are calculating the values in the 3rd column.


Dear Seenivasan,

You ended my problem troubled during last two days. Thank you very much. Thank you very much for your solution and the great way of explanation.