title: Yii Framework - CGridView sort related columns
body: <p>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.</p>
  
  <p>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. </p>
  
  <p>This is what I have:</p>
  
  <p>The relation name/label is "company," setup in Employee model.</p>
  
  <p>Table: Employee -- Column: idCompany
  &amp;
  Table: Company -- Column: companyNick</p>
  
  <p>admin.php - VIEW</p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.grid.CGridView', array(
      'id'=&gt;'employee-grid',
      'dataProvider'=&gt;$model-&gt;search(),
      'filter'=&gt;$model,
      'columns'=&gt;array(
              array(
                      'name'=&gt;'company',   
                      'value'=&gt;'$data-&gt;company-&gt;companyNick',
              ),
              'lastName',
              'firstName',
  
  ETC...
  </code></pre>
  
  <p>Employee.php - MODEL</p>
  
  <pre><code>public function search()
      {
              // Warning: Please modify the following code to remove attributes that
              // should not be searched.
  
              $criteria=new CDbCriteria;
  
              //Company Relation Search
              $criteria-&gt;compare('company.companyNick',$this-&gt;company,true);  
              $criteria-&gt;with='company'; 
  
              //stock
              $criteria-&gt;compare('idEmployee',$this-&gt;idEmployee,true);
              $criteria-&gt;compare('idAccount',$this-&gt;idAccount,true);
  
  ETC...
  </code></pre>