Cgridview Display Link Or Plain Text Based On Value Of Another Column


I have a gridview that displays if a payment has been made. If the payment has been made, a date appears in the "Date Paid" column for that row, otherwise it is blank.

What I want to do in the column next to it is display "Paid" text if a date exists on a row, otherwise I want to display a link labelled "Pay Now" that when clicked will call a url to update the paid date field in the underlying table and in turn update the data paid column (page can just refresh, not important for it to be ajax).

I have used ‘url’ => array($this, ‘fnFunctionName’) to customise urls for CColumnButton type columns in other grid views I have but I havent been able to come up with any code that will achieve what I want.

I guess what I am looking for is how to format the entire cell based on a function that uses if then else to return either a plain text label, or a link to the desired url on a row by row basis.

Any help would be appreciated.

Greg J





            'header'=>'Some Header',


                if (/* determine if paid here from $data */)

                    return 'Paid';

                return CHtml::link('Pay Now', array('/your/path/here'));






simple and exactly what I needed. thank you very much keith!

Greg J