CGridView filter

Hi all.

I’ve some question about filtering data in CGridView.

After forum search i found some examples, like this







so, i must define in model function "search" CDbCreteria with params… but if i want pagination and default data filtration?

which way is better - put pagination and default filter in model, or use controller to work with filter?


sorry for my english :)

If you need a ‘default data filtration’ maybe you can use the default scope.

Otherway you can add condition to the model in the controller function (or edit the search() method).

Any method is equivalent, anyway is better to respect MVC: if your condition depends from user input, should be the controller to manage them, if your condition are just depending from model’s data, better to do in the model

zaccaria, how to access filtered data and put in our own element (div with ID)? not just displayed it in CGridView.