title: Filtering and sorting doesn't work in Yii2
body: <p>I know there were some questions related to this, but they couldn't help me out.</p>
  
  <p>I have generated <code>GridView</code> which has <code>Sale</code> model, I added new column, which is from different table, it's named <code>price</code>. Now I want to add sorting and filtering to it, but somehow it doesn't work..</p>
  
  <p>Here is my steps what I'm doing:</p>
  
  <p>Step 1: adding function <code>getItemPrice</code> into my <code>Sale model</code>:</p>
  
  <pre><code>/* Gets item price*/
  public function getItemPrice()
  {
      return $this-&gt;item-&gt;price;
  }
  </code></pre>
  
  <p>Step 2: defining price rule in <code>SaleSearch</code>model:</p>
  
  <pre><code>/**
  * SaleSearch represents the model behind the search form about `app\models\Sale`.
  */
  class SaleSearch extends Sale
  {
  public $price;
  /**
   * @inheritdoc
   */
  public function rules()
  {
      return [
          [['id', 'item_id', 'sign'], 'integer'],
          [['customer_name', 'customer_surname', 'customer_phone', 'customer_email', 'code', 'comment'], 'safe'],
          [['price'], 'double'],
      ];
  }
  </code></pre>
  
  <p>Step 3: adding <code>setSort()</code> into the same model and wrinting <code>joinWith</code> statement :</p>
  
  <pre><code>public function search($params)
  {
      $query = Sale::find();
      // add conditions that should always apply here
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
      ]);
  
      $query-&gt;joinWith('item');
      $dataProvider-&gt;setSort([
          'attributes' =&gt; [
              'customer_name',
              'customer_surname',
              'customer_phone',
              'customer_email',
              'code',
              'comment',
              'sign',
              'price' =&gt; [
                  'asc' =&gt;['tbl_item.price' =&gt; SORT_ASC],
                  'desc' =&gt;['tbl_item.price' =&gt; SORT_DESC],
              ],
              'item_id' =&gt; [
                  'asc' =&gt;['item.name' =&gt; SORT_ASC],
                  'desc' =&gt;['item.name' =&gt; SORT_DESC],
              ]
          ]
      ]);
  
      $this-&gt;load($params);
  
      if (!$this-&gt;validate()) {
          // uncomment the following line if you do not want to return any records when validation fails
          // $query-&gt;where('0=1');
          return $dataProvider;
      }
  
      // grid filtering conditions
      $query-&gt;andFilterWhere([
          'id' =&gt; $this-&gt;id,
          'item_id' =&gt; $this-&gt;item_id,
          'sign' =&gt; $this-&gt;sign,
      ]);
  
      $query-&gt;andFilterWhere(['like', 'customer_name', $this-&gt;customer_name])
          -&gt;andFilterWhere(['like', 'customer_surname', $this-&gt;customer_surname])
          -&gt;andFilterWhere(['like', 'customer_phone', $this-&gt;customer_phone])
          -&gt;andFilterWhere(['like', 'customer_email', $this-&gt;customer_email])
          -&gt;andFilterWhere(['like', 'code', $this-&gt;code])
          -&gt;andFilterWhere(['like', 'comment', $this-&gt;comment]);
  
      return $dataProvider;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My <code>GridView</code>:</p>
  
  <pre><code>    &lt;?= GridView::widget([
      'dataProvider' =&gt; $dataProvider,
      'filterModel' =&gt; $searchModel,
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
  
          [
              'attribute' =&gt; 'item_id',
              'value' =&gt; 'item.name',
          ],
          'code',
          'customer_name',
          'customer_surname',
          'customer_phone',
          [
              'attribute' =&gt; 'price',
              'value' =&gt; function($model) {
                  return $model-&gt;item-&gt;price;
              },
          ],
          [
              'attribute' =&gt; 'sign',
              'value' =&gt; function ($model) {
                  return $model-&gt;sign == 1 ? 'Apmokėtas' : 'Neapmokėtas';
              },
          ],
  
          // 'customer_email:email',
          //  'comment:ntext',
  
          ['class' =&gt; 'yii\grid\ActionColumn'],
      ],
  ]); ?&gt;
  </code></pre>
  
  <p>After writing code like that, my all <code>GridView</code> now has no sorting or filtering at all. Could someone tell me what I'm doing wrong? </p>