Cdatacolumn::renderfiltercellcontent And Filterhtmloptions

Hi,

Trying to set filterHtmlOptions for a gridview and noticed the CDataColumn’s renderFilterCellContent() isn’t applying the filterHtmlOptions property. Can someone confirm this or am I being dumb?

https://github.com/y...aColumn.php#L95

Grid Code:





array(

            'name' => 'category_id',

            'filter' => CHtml::listData($categoryList, 'id', 'text'),

            'filterHtmlOptions' => $categoryList,

            'value' => '$data->category->buildParentsList()',

            'htmlOptions' => array(

                'class' => 'span5'

            )

        ),



CDataColumn.php





protected function renderFilterCellContent()

{

    if (is_string($this->filter))

        echo $this->filter;

    elseif ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false)

    {

        if (is_array($this->filter))

            echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => ''));

        elseif ($this->filter === null)

            echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false));

    }

    else

        parent::renderFilterCellContent();

}



should be?




// Notice: ...'options' => $this->filterHtmlOptions

protected function renderFilterCellContent()

{

    if (is_string($this->filter))

        echo $this->filter;

    elseif ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false)

    {

        if (is_array($this->filter))

            echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => '', 'options' => $this->filterHtmlOptions));

        elseif ($this->filter === null)

            echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false));

    }

    else

        parent::renderFilterCellContent();

}



Thanks,

Matt

Dear Waterloomatt

What I have understood after going through CGridColumn.php and CDataColumn.php is

that filterHtmlOptions are only meant for filtercell td not for filtercell content.

CGridColumn.php




abstract class CGridColumn extends CComponent

{

public function renderFilterCell()

	{

	  echo CHtml::openTag('td',$this->filterHtmlOptions);//filterHtmlOptions gives attributes to td cell

	  $this->renderFilterCellContent();

	  echo "</td>";

	}


protected function renderFilterCellContent()

	{

		echo $this->grid->blankDisplay;

	}

}



CDataColumn.php




class CDataColumn extends CGridColumn

{

protected function renderFilterCellContent()

	{

		if(is_string($this->filter))

			echo $this->filter;

		else if($this->filter!==false && $this->grid->filter!==null && $this->name!==null && strpos($this->name,'.')===false)

		{

			if(is_array($this->filter))

				echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id'=>false,'prompt'=>''));

			else if($this->filter===null)

				echo CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false));

		}

		else

			parent::renderFilterCellContent();

	}

}



This will be evident if we make a column like this.




array(

	'name'=>'someAttribute',

	'filterHtmlOptions'=>array('style'=>"background:gold;"),

	'filter'=>false

		),



Regards.

Thanks, Too bad - would have been nice to do something like this.

3567

drop_down.jpg