Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Cgridview: rowCssClassExpression and cssClassExpression have a small bug #1163

smertnik77 opened this Issue · 11 comments

5 participants


makes the html code
<td class>

I mean, even a blank value will be added to the class

@cebe cebe was assigned

cssClassExpression is from CgridColumn of course)

@cebe cebe referenced this issue from a commit in cebe/yii
@cebe cebe fixed empty css class attribute for CGridColumn
fixes #1163

problem also existed in CGridView now also fixed in CGridColumn.


I'm not sure this is a problem/bug in the first place.

@smertnik77, where are you looking when you conclude that the result is <td class></td>? I am guessing you looked in Chrome's developer tools or something like that, and not in the actual HTML source code that is sent to the browser.

Looking at the diffs from @cebe's commits, my impression is that what was previously output isn't <td class></td> but rather <td class=""></td>, and IMO that is valid HTML. It's just a class attribute that doesn't have any classes in it.

I also tested this now and I do get the class="" for the following code:


$dataProvider=new CArrayDataProvider(array(
    array('id'=>'Foo1', 'bar'=>'Bar1'),
    array('id'=>'Foo2', 'bar'=>'Bar2'),

$this->widget('zii.widgets.grid.CGridView', array(

Yii::app()->clientScript->registerCss('foo', '
    background-color: red;

If on the other hand people prefer not to have the class output when it's empty, I think that's fine. But it's hardly a bug.


I agree with @rawtaz the output is all standard as the quotes are there, so this "fix" is not really needed but if it's requested we can add it.


So do we want to "fix" it? @mdomba @samdark @qiangxue ?

One other case that can occur is <tr class="myclass "> with a whitespace inside attribute value, but I think it is still valid html then.


@smertnik77 was your bug report about the missing ="" or about an empty class attribute?


IMO it would be more elegant to have clean HTML code so I'm for adding this simple fix.


Thats also how I see it, vote for it. @rawtaz changed label from Bug -> Enhancement ;-)


Agree with @mdomba about having clean HTML code, so good micro-enhancement.


Good @cebe. We should do this with many more issues marked as bugs, i.e. make them features ;)


@cebe - about an empty class attribute, I know english bad, sorry

@cebe cebe closed this issue from a commit
@cebe cebe CGridview does not create empty class attribute
fixes #1163 where rowCssClassExpression or rowCssClass could be empty
for certain rows.
@cebe cebe closed this in 7428985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.