title: yii CGridView filter with relations
body: <p>I'm using yii for my web application. In one of my view I have CGridView and dataprovider is Mail model. In this model I have relation with with 3 other models. In the grid I show cols from three models. How can I filter the CGridView?</p>
  
  <p>UPDATE:</p>
  
  <pre><code>&lt;?php $dialog = $this-&gt;widget('ext.ecolumns.EColumnsDialog', array(
             'options'=&gt;array(
                  'title' =&gt; 'Layout settings',
                  'autoOpen' =&gt; false,
                  'show' =&gt;  'fade',
                  'hide' =&gt;  'fade',
              ),
             'htmlOptions' =&gt; array('style' =&gt; 'display: none'), //disable flush of dialog content
             'ecolumns' =&gt; array(
                  'gridId' =&gt; 'mails-grid', //id of related grid
                  'storage' =&gt; 'session',  //where to store settings: 'db', 'session', 'cookie'
                  'fixedLeft' =&gt; array('CCheckBoxColumn'), //fix checkbox to the left side 
                  'model' =&gt; $dataprovider, //model is used to get attribute labels
                  'columns'=&gt;array(
                                  array(
                                      'name'=&gt;'mailTemplate.name',
                                      'filter'=&gt;CHtml::activeTextField($dataprovider, 'mailTemplate'),
                                  ),
                                  'sendDate',
                                  array(
                                          'name'=&gt;'mailTemplate.subject',
                                          'filter'=&gt;CHtml::activeTextField($dataprovider, 'mailTemplate'),
                              ),
                              array(
                                  'name'=&gt;'client.email',
                                  'filter'=&gt;CHtml::activeTextField($dataprovider, 'client'),
                              ),
                              array(
                                  'name'=&gt;'client.name',
                                  'filter'=&gt;CHtml::activeTextField($dataprovider, 'client'),
                              ),
                              array(
                                  'name'=&gt;'operator.username',
                                  'filter'=&gt;CHtml::activeTextField($dataprovider, 'operator'),
                              ),
                              array(
                                  'name'=&gt;'status',
                                  'value'=&gt;array('MailHelper', 'getEmailStatus'),
                                  'filter'=&gt; CHtml::activeDropDownList($dataprovider, 'status', Mail::getEmailStatuses()),
                              ),
                              array(
                                  'class'=&gt;'CButtonColumn',
                                  'template'=&gt;'{update}',
                                  'buttons'=&gt;array(
                                                  'update' =&gt; array(
                                                          'url'=&gt;'$this-&gt;grid-&gt;controller-&gt;createUrl("/email/editTemplate", array("templateId"=&gt;$data-&gt;id))',
                                                  ),
                                              ),
                              )
                          ),
          )
      ));
  </code></pre>
  
  <p>?></p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.grid.CGridView', array(
      'id' =&gt; 'mails-grid',
      'dataProvider'=&gt;$dataprovider-&gt;search(),
      'columns' =&gt; $dialog-&gt;columns(),
      'filter' =&gt; $dataprovider,
      'template' =&gt; $dialog-&gt;link()."{summary}\n{items}\n{pager}",
  )); ?&gt;
  </code></pre>