CGridView Custom Values

Can’t we use following statement to compute value of particular column?





I am getting following PHP error:

Undefined variable: userList

I am setting $userList in side action method & passing to this view which contain CGridView.

The ‘value’ field contains code which is evaluated inside a function (using php eval() function). Thus the scope of variables is not the one from your view (the global scope).

I have been in the case where I needed a constant so I was using ‘define’ and could access it. But I have not been in the case where I need external variables, maybe by looking at the comments here you will find something. Try looking at $GLOBALS as well…

Why don’t you just create a lookup object or function?

$userList[$data->jobseeker->managed_by_id][2] for UserList::getManagedBy($data->jobseeker->managed_by_id)

I rather do that instead of playing with globals. Just another option

I agree. I do it a lot for formatting values, and I recommend the use of static functions.

But if you pull data from your db, it will considerably increase the number of queries. It has to be kept in mind.