php - Show cgridview data based on condition


Is this possible to show cgridview data using condition. like only show those data where status=1.

$this->widget('zii.widgets.grid.CGridView', array(



The table have status 0 and 1. I only want those listings which status is 1.

UPDATE: if i changed search method like this


It's worked perfectly. But is it a good practice?




You show data from model in CGridView. You can add conditions as criteria. For example in your model in search method add

$criteria->addCondition('status = 1');

People are also looking for solutions to the problem: php - Smarty: cannot replace string


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.