Yii Framework Forum: TbExtendedGridView - row colors - Yii Framework Forum

Jump to content

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

TbExtendedGridView - row colors I want to change the background color based on a data value. Rate Topic: -----

#1 User is offline   RandyCoots 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-October 17

Posted 30 October 2017 - 05:32 PM

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.yiiframew...lor+#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
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,387
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 31 October 2017 - 12:19 AM

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
0

#3 User is offline   RandyCoots 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-October 17

Posted 31 October 2017 - 10:43 AM

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