CGridView sort related column

[size=“4”]Thanks in advance to anyone who can help. I’ve been searching for an answer, but haven’t found one yet. I’ve run into “solutions” that haven’t worked that run from 1 line, to re-writing an entire class.

I’ve got the “grid” to show the relation, and am able to use the search feature. What I can’t figure out is the sort feature. The column header becomes non-clickable once the below changes have been made.

This is what I have:[/size]

The relation name/label is "company," setup in Employee model.

Table: Employee – Column: idCompany


Table: Company – Column: companyNick

admin.php - VIEW

<?php $this->widget('zii.widgets.grid.CGridView', array(












Employee.php - MODEL

public function search()


		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;

		//Company Relation Search








In the dataprovider you have to edit the property sort=>attributes;

Take a look at the doc.