Hiding/filtering row results in CGridView

Hi all, I did some forum searching and googling to no avail.

I’m trying to determine the easiest and best-practice way to prevent certain row results from showing in a CGridView. I’d like the row to only show in my CGridView if my model for that row has a value of “yes” for a specific attribute.

Many thanks to anyone that can point me in the right direction.

did you play with the filter option. I don’t know any direct config that can determine if a row should be displayed or no. You can apply logic whether to display a certain cell but not sure if that is your question.

I had looked into it, but it looked like that was just for getting rid of the search textboxes at the top of each column. Perhaps I misunderstood the documentation?


I think I figured out an easy way to do this. I hope this helps someone in the future.

Instead of filtering rows from the CGridView, I modified its dataprovider to filter the data. I simply had to go to my model and add an additional criteria to my search method:

$criteria->addCondition(“visible = ‘yes’”); // visible is the name of my model attribute my filter is based upon