Filtering For Null Fields With A Gridview

Hi,

I’m working on a small custom ticket system. In addition to an Admin action, I’m trying to implement a Queue action. The desired output of this would simply be the tickets that don’t have a close date.

I’ve tried this:


	public function actionQueue()

	{

		$model=new Ticket('search');

		$model->unsetAttributes();  // clear any default values

		

		//$model->attributes=(array('id'=> '10'));

		$model->attributes = (array('ticket_close_date'=> null));

		

		$this->render('queue',array(

			'model'=>$model,

		));

	}	



But, I still get the full list of tickets, ones that are open and closed.

If I swap the Attribute lines (uncomment the 1st, comment the second), I get a single record for ID 10 in my table.

What am I missing to get a list that matches this SQL: "SELECT * FROM ticket WHERE ticket_close_date is null" ?

Figured this out after more searching and experimenting:

In my controller:


	public function actionQueue()

	{

		$model=new Ticket('search');

		$model->unsetAttributes();  // clear any default values

		

		$dataProvider = $model->search();

		$dataProvider->criteria->addCondition('ticket_close_date is null');

		

		$this->render('queue',array(

			'model'=>$model, 'dataProvider'=>$dataProvider,

		));

	}	



And in my View (queue.php):


<?php $this->widget('bootstrap.widgets.TbGridView', array(

	'id'=>'ticket-grid',

	'type'=> array(TbHtml::GRID_TYPE_CONDENSED,

				   TbHtml::GRID_TYPE_HOVER,

				   TbHtml::GRID_TYPE_BORDERED,

				   TbHtml::GRID_TYPE_STRIPED),

	'dataProvider'=>$dataProvider,

...