Yii Framework Forum: Inconsistency With Rowhtmloptionsexpression - Yii Framework Forum

Jump to content

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

Inconsistency With Rowhtmloptionsexpression Rate Topic: -----

#1 User is offline   hlob 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 30-December 12

Posted 30 December 2012 - 06:05 PM

Hi,
there is a slight inconsistency with the new (and very useful! )rowHtmlOptionsExpression property of CGridView in CGridView's renderTableRow($row):

if($this->rowHtmlOptionsExpression!==null)
		{
			$data=$this->dataProvider->data[$row];
			$options=$this->evaluateExpression($this->rowHtmlOptionsExpression,array('row'=>$row,'data'=>$data));
			if(is_array($options))
				$htmlOptions = $options;
		}
                
		if($this->rowCssClassExpression!==null)
		{
			$data=$this->dataProvider->data[$row];
			$class=$this->evaluateExpression($this->rowCssClassExpression,array('row'=>$row,'data'=>$data));
		}
		elseif(is_array($this->rowCssClass) && ($n=count($this->rowCssClass))>0) {
			$class=$this->rowCssClass[$row%$n];
                        
                }

If you look at this, you'll see that in the case of a rowHtmlOptionsExpression being present, the default styles are still added. For my current requirements I solved it with an additional if condition:

elseif(is_array($this->rowCssClass) && ($n=count($this->rowCssClass))>0 [b]&& $this->rowHtmlOptionsExpression==null[/b]) {

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