[SOLVED] Custom footer vanishes when sorting CGridView

Hello, I extended the CGridView, CLinkColumn, CDataColumn classes to render custom footer row form (for editing the entries) but every time I sort the grid the footer row vanishes. How does one prevent that from happening?

Here are my custom classes:




Yii::import('zii.widgets.grid.CGridView');


class FormGridView extends CGridView {

    

    public $formId = "mform";

    public $formAction = "";


    public function init(){

        parent::init();

        //$this->enableSorting = false;

    }

    public function registerClientScript(){

        parent::registerClientScript();

        $cs=Yii::app()->getClientScript();

        $cs->registerScriptFile(Yii::app()->baseUrl . '/js/transfer.js');

        $cs->registerCssFile(Yii::app()->baseUrl . '/css/ajaxedit.css');

    }


    public function renderTableFooter(){

        echo "<form id=\"$this->formId\" action=\"$this->formAction\" method=post>";

        parent::renderTableFooter();

        echo "</form>";

    }


}






Yii::import('zii.widgets.grid.CButtonColumn');

class CustomButtonColumn extends CButtonColumn{


    public $primaryKeyName = "id";


    public function init(){

        parent::init();

        $this->footer = '<input type=submit value=Add name=sbutton>' .

             CHtml::hiddenField($this->primaryKeyName, "");

    }


}






Yii::import('zii.widgets.grid.CDataColumn');


class FieldColumn extends CDataColumn{


   public $fieldSize;


   public function init(){

        parent::init();

        $this->footer = CHtml::textField($this->name, '',

            array('size'=> $this->fieldSize));

    }




}






Yii::import('zii.widgets.grid.CLinkColumn');


class HiddenFormColumn extends CLinkColumn{


    //public $dialogUrl;

    public $formIdPrefix = "mform";

    public $buttonHtmlOptions = array('class'=> "unb");

    

    public function init(){

        parent::init();

        $this->footerHtmlOptions['id'] = $this->grid->formId . "pk_display";

        $this->footer = 'New Entry';

        $this->header = "<form action=\"javascript:showNew('" . $this->grid->formId 

                . "');\" ><input type=submit value=New class=unbhdr></form>";

    }


    protected function renderDataCellContent($row,$data){

        $tformId = $this->formIdPrefix . $data->primaryKey;

        echo "<form action=\"javascript:showEdit('$tformId','" . $this->grid->formId 

                . "');\" id=\"" . $tformId . "\">" ;

        foreach ($data as $key => $value) {

            echo CHtml::hiddenField($key, $value);

        }

        echo CHtml::hiddenField('pk', $data->primaryKey);

        echo CHtml::hiddenField('sbutton', "Edit");

        echo CHtml::submitButton($data->primaryKey, $this->buttonHtmlOptions);

        echo '</form>';

    }

}



bump

what is the resulting HTML once you sort? Have you checked it?

I do have my own widgets and never had that problem…

You obviously set the extended Grid footer, even on ajax calls right? …

The whole footer HTML element in the table seems to be grayed out in Firebug.

EDIT: Strange, the JavaScript function that changes the form elements values still works in setting the values but the whole footer element is invisible. Hmm, it actually might be a CSS visibility problem.

Make sure the table footer is a separate layer of the table body… if grayed out then it is clear that is a CSS js modification…

I tried making it visible via afterAjaxUpdate but still no dice.

EDIT: finally made it work by making the form itself visible. Thanks very much for the tip.