enoc22
(Hauver 1)
1
Hi All,
I’m building a ticket system for a client.
Each ticket has 3 statuses pending, processing and complete.
I’ve been trying to figure out how to create a view(with CGridView) to show only pending and processing tickets.
I can set $model->status = ‘<>complete’ but i want to be able to search/filter the resulting pending/processing tickets.
I’ve found ‘condition’ in my model’s search function can do the limiting but it does it for all views, i’m trying to get a limit for just this view.
I’ve also seen findAllByAttributes which could work, but it’s more work to get all the search/filter functionality up and running
Is there any way in my controller to limit/pre-filter results?
Thanks
Oliver
rootbear
(Alex Xm)
2
i would do, in controller
if (!isset($_GET['Ticket']))
//initial filter here - pending and processing tickets;
else
//no filter - regular search
wisp
(Wisp)
3
enoc22
(Hauver 1)
4
@rootbear I would like to do it in the controller, Can you apply filters that will not show in the grid’s filter text boxes.
@wisp That looks very usefull. Any idea how i would implement it in my controller? this is my action funcition (for CGridView):
public function actionOpen(){
$model=new Ticket('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Ticket']))
$model->attributes=$_GET['Ticket'];
$this->render('index',array(
'model'=>$model,
));
}
Thanks for your responses
Oliver
wisp
(Wisp)
5
rootbear
(Alex Xm)
6
thanks a lot @wisp, very helpful
wisp
(Wisp)
7
Nice to hear, I’ll write some more articles if people are interested…