title: PHP Yii: how to row numbering CGridView if using sqlite database
body: <p>I want to show a filter-able and sort-able column of row number in CGridView, but what i have got is only an empty sort-able (clickable header) and filter-able (it has filtering text box up there) column.</p>
  
  <p>In model (ActiveRecord) class i have added a new public attribute:</p>
  
  <pre class="lang-php prettyprint-override"><code>public $number;
  </code></pre>
  
  <p>in the rules() function i have added:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function rules()
  {
      return array(
          ...
          ...
          array('
              ...
              ...
              number,
              ',
              'safe',
              'on'=&gt;'search'
          ),
      );
  }
  </code></pre>
  
  <p>on the search() function, i have also add:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function search()
  {
  $criteria=new CDbCriteria;
  ...
  ...
  $number_select = '( 
      select count(*)
      from tbl_mytable as k
      where k.id &lt;= t.id
      )';
  $criteria-&gt;select = array(
      $number_select . ' as number',
      't.*',
      );
  ...
  ...
  $criteria-&gt;compare($number_select, $this-&gt;number,true);
  $sort = new CSort;
  $sort-&gt;attributes = array(
      '*',
      ...
      ...
      'number'=&gt;array(),
      );
  
  return new CActiveDataProvider($this, array(
      'criteria'=&gt;$criteria,
      'sort'=&gt;$sort,
  ));
  }
  </code></pre>
  
  <p>I've successfully using this kind of method to add other columns.
  With the lack of skill and knowledge of sqlite query, i am suspecting the cause of this problem is the query in the <code>$criteria-&gt;select</code>.</p>
  
  <p>I hope someone would help me for solving this.</p>