I am using widgets.TbGridView,

I have a column "priority" values are 0,1, or2

I need to use css for every row depending to priority value.

How I can use rowCssClassExpressionin in this case, because all the example I can find is a condition sentence as :


If I try to use a function example:


I get the error Undefined variable: data

You could do it in several ways, but here are two that I think will work:

// Option one: evaluate as a string


// Option two: use an anonymous function

'rowCssClassExpression'=>function($row, $data){

    return getCssClass($data['priority']);


I think the best solution is to make a function in the model that outputs the class name, and you call it like this: