CGridView Footer like Header?

Hi there!

First of all I have to say that I really appreciate working with YII. It’s kind of magic how easy one can set up a complex web application with only some lines of code! Great work…!

Now my question:

is ist possible to have the header of a cgridview-table repeated as a footer with the same sorting possibilities as in the header? the attribute “footer” doesn’t seem to do the job for me…

Thanks in advance!


Hi and welcome,

i think it’s not possible by default. But you could try to solve this with some OOP style extending: First find out, where the header and footer are rendered by default (it’s done by some methods in CGridColumn/CDataColumn). Then you could create your custom column type class and override renderFooterCell() like this:


class MyDataColumn extends CDataColumn


    public function renderFooterCell()


        echo CHtml::openTag('td',$this->footerHtmlOptions);


        echo '</td>';



Then configure this class in your column definition.

I didn’t test this code, so maybe you have to tune a little. But eventually you should get it working.

Mike, thanks a lot for your really fast answer!

Your solution sounds good and elegant - I’ll test it and inform you about my progress…

Best, Tobi