[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(
'id'=>'employee-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'company',
'value'=>'$data->company->companyNick',
),
'lastName',
'firstName',
ETC...
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
$criteria->compare('company.companyNick',$this->company,true);
$criteria->with='company';
//stock
$criteria->compare('idEmployee',$this->idEmployee,true);
$criteria->compare('idAccount',$this->idAccount,true);
ETC...