Yii Framework Forum

CGridColumn::filterHtmlOptions - missing property?


(Kiaplayer) #1

Hello.

There are some properties in CGridColumn for adding special html options:




/**

 * @var array the HTML options for the data cell tags.

 */

public $htmlOptions=array();

 

/**

 * @var array the HTML options for the header cell tag.

 */

public $headerHtmlOptions=array();

  

/**

 * @var array the HTML options for the footer cell tag.

 */

public $footerHtmlOptions=array();



But there is no such property for filter cells. It can be implemented like this:




/**

 * @var array the HTML options for the filter cell tag.

 */

public $filterHtmlOptions=array();


/**

 * Renders the filter cell.

 */

public function renderFilterCell() {

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

  $this->renderFilterCellContent();

  echo "</td>";

}



For example, without this you cannot hide column with style="display:none;" (filter cell will be visible).


(Mailmohitp) #2

Thanks for this info.

It helped me save lot of frustration. I feel that this feature should have been implemented in Yii itself, rather than having us modify the inbuilt Yii files.


(Maurizio Domba Cerin) #3

If you don’t want the filter for a specific column… you can set it’s filter property to false - http://www.yiiframework.com/doc/api/1.1/CDataColumn#filter-detail


(Regularmike) #4

Yes, but this has the effect of rendering


<td>&nbsp;</td>

, when you might sometimes want to hide the entire cell instead.