Sortable With Joined Table Fields

I cannot seem to get my CGridView to be sortable with any fields that are joined from other tables. Populating the data is fine, sorting on a field that is part of the immediate table works fine as well.

Here is my example query:

SELECT -> t.*, tableA.testFieldA, tableB.testFieldA as testFieldB

JOIN -> tableC ON (t.tableC_ID = tableC.id)

JOIN -> tableB ON (tableC.tableB_ID = tableB.id)

JOIN -> tableA ON (t.tableA_ID = tableA.id)

In the CGridView:




columns => array(

    array(

        'header' => 'Date',

        'name' => 'date', // Works cause it is in the immediate table

    ),

    array(

        'header' => 'Test Field B',

        'name' => 'testFieldB' // Doesn't sort, alias or no alias

    ),

);



Resolved by following this little link that someone gave me.

http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview/