Cgridview dropdown as a filter?

Let’s say I have a table called tbl_transactions and in that table there is a field for customer_id, date_paid,category_id, etc. Is there a way to have dropdowns to use as filters at the top of the cgridview? For example, the customer_id is the foreign key for the customer table. What I would like to have is a dropdown at the top of the grid that is populated with distinct values of all customers who have transactions and then filter the recordset based on selected index with the onchange event. Same with the category_id. Has anyone implemented something like this?

Yes, this feature is large implemented on Yii Framework via "filters", and fully demostrated when you perform a search in a CRUD-Gii generated code.

When you create a new CRUD for any model you’'ll find that the actionAdmin works using a search mechanism, this code implements a search. You must learn a little bit more deeply on yii to known and handle this task, because you must understand in more clear way the Yii Funcionality about MVC.


        'name' => 'cat_id',

          'filter' => CHtml::dropDownList('Article[cat_id]', $model->cat_id, CHtml::listData(catproduct::model()->findAll(), 'id', 'title'), array('empty' => 'choose...')),