How do I calculate a column in CgridView?


I have a qty and price for each row and I want to calculate the extended price.

I also want to total this value.

(qty * price) = extended price.

I have searched the forum, but cannot get this working.

Thanks for the help.


in your model:

public function getExtendedPrice()


	return $this->qty * $this->price;


access with:


Thanks, that works great.

How can I also total the result in the footer?

I appriciate the help.

in your ExtentedPrice column you can use the property ‘footer’:

you must create a function to sum each line for you

Thank you,

This seems to be working.








public function getExtTotals()


		$exttotal = 0;

		$cart = $this->getCart();

		foreach ($cart as $row)

			$exttotal += $row->ct_price * $row->ct_qty;

		return number_format($exttotal,2);