TbExtendedGridView - row colors

I am very new to yii, have been going thru tutorials, and looking at forum posts. I see several forum posts on this topic, but all my attempts so far have failed.

I am attempting to modify an existing application for support tickets. We have a process where a support rep must assign the ticket to a support group level, then the ticket must be acknowledged by the support group the ticket was assigned to. We get emails after 15 minutes warning that the ticket hasn’t been acknowledged. Until we receive the email, we don’t necessarily know which tickets have and have not been acknowledged. I want to set the background color in the TbExtendedGridView listing of the tickets based on whether the ticket has been acknowledged.

I’ve looked at this posting http://www.yiiframework.com/forum/index.php/topic/7646-cgridview-how-to-color-rows-depending-on-data-values/page__p__38802__hl__cgridview+color+#entry38802 which details how to set the color attributes using rowCssClassExpression.

So far every time I attempt to use this setting it completely disables my gridview.

I have attempted to add a function to the tickets.php file, which is my class definitions for the tickets class.

/*public function getColor($colorstr as string) {

	// $colorstr in value passed from calling function


	// if empty, no value set - return 'green'


	// if not empty, ie.. value is set - return 'white'


	$colorstr = 'white';  // defaults to value being set


	


	if strlen(trim($colorstr)) == 0) { $colorstr = 'green';}   // value not set


	


	return $colorstr;


		


} 


*/

any time I uncomment this function I get an error, even though there is nothing calling this function.

I’m attempting to determine which css file is used for the TbExtendedGridView, I don’t see any statement in the class file which specifies the default css file for this. I’ve looked at the main.css and override.css files, so far unable to affect the grid row background color when I make changes. I’ve modified the odd and even color settings, in the override.css file, but it has no affect.

Searching in the documentation didn’t help with this at all, there was no mention of color parameters for the row in the CGridView portion of the document. There was nothing about TbExtendedGridView at all.

I would appreciate any assistance, pointers etc…

Thanks,

Randy

reason you get an error when you remove comment is because you have typo in your code, the beginning parentheses of your if statement are not there also the type casting is messed up in your function definition, try this




<?php


public function getColor((string)$color)

{

    // $colorstr in value passed from calling function

    // if empty, no value set - return 'green'

    // if not empty, ie.. value is set - return 'white'

    $color = 'white';


    if (strlen(trim($color)) == 0) {

        $color = 'green';

    }


    return $color;

} 



btw the logic in your code is all messed up it will always return white

Thank you for the feedback Alrazi, I’ll be working out any issues with that function down the road.

What I really need to know is where to define that function, currently its in the class definition for my tickets class.

Also, I’m trying to determine what css file is the default css file for the TbExtendedGridView widget.

Thanks again for any information you can provide, I’m not finding any documentation on this.