Cgridview And Searching Using External Textfield

Hello:

I’m hoping there’s a way to do this. Basically I’m trying to use a date picker field that sits OUTSIDE of the grid view to trigger the grid searching. So the datepicker is tied to the model and then I’m triggering an update to the gridview. But the gridview is not performing the search. Is there a way I can accomplish this? I’ve included my code.

Thanks!




	<div class="left">

		<?php 

			$this->widget('zii.widgets.jui.CJuiDatePicker', array(

				'id'=>CHtml::activeId($model, 'order_date'),

				'model'=>$model,				

				'attribute'=>'order_date',

					'options'=>array(

							'showAnim'=>'fold',

							'dateFormat'=>'yy-mm-dd',

					),

			));


			$this->widget('zii.widgets.jui.CJuiButton',array(

				'name'=>'search',

				'buttonType'=>'button',

				'caption'=>'Search',

				'options'=>array(

					'icons'=>array('primary'=>'ui-icon-search'),

				),

				'htmlOptions'=>array('width'=>'50px','height'=>'22px'),

				'onclick'=>'js:function(){        													

					$.fn.yiiGridView.update("order_grid");					

        			return false;}',

        		)

			);


		?>

	</div>

	

	<div class="centre">

		<?php 		

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

				'id'=>'order_grid',

				'dataProvider'=>$model->search(),

				'showTableOnEmpty'=>true,

				'template'=>"<b>Orders</b> {pager}\n{items}\n{pager}",

				'filter'=>$model,

					

				'columns'=>array(

					'cc_transaction_id',

					array(

						'name'=>'order_id',

						'htmlOptions'=>array('align'=>'right'),

					),

					array('name'=>'order_status',

						'htmlOptions'=>array('align'=>'right'),		

					),

					array(

						'name'=>'order_date',

						'value'=>'date_format(date_create($data->order_date),"Y-m-d")',

						'htmlOptions'=>array('align'=>'right'),

					),

					array(

						'name'=>'cc_last_name',

						'header'=>'Customer',

						'htmlOptions'=>array('align'=>'right'),

						'value'=>'$data->cc_first_name." ".$data->cc_last_name',

					),

					array(

						'name'=>'cc_number',

						'header'=>'Card Number',

						'htmlOptions'=>array('align'=>'right'),

						'value'=>'$data->cc_type."-".substr($data->cc_number,12,4)',

					),

					array(

						'name'=>'capture_amount',

						'htmlOptions'=>array('wdith'=>'80', 'align'=>'right'),

						'header'=>'Net Capture Amount',

						'value'=>'netAmount($data)',

					),

				),			

			));	

			

		?>

	</div>




Why don’t you use the “Advanced Search Form” of the gii generated admin page as the skeleton?

What you have to do will be just replace the text field of ‘order_date’ with a date picker. :)

That worked perfectly! Thanks so much.