Yii Framework Forum: Cdatacolumn::renderfiltercellcontent And Filterhtmloptions - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdatacolumn::renderfiltercellcontent And Filterhtmloptions Rate Topic: -----

#1 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 03 December 2012 - 08:53 AM

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
0

#2 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 04 December 2012 - 10:03 AM

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.
0

#3 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 04 December 2012 - 10:41 PM

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

Attached File  drop_down.jpg (53.73K)
Number of downloads: 8

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users