Using Cjuidatepicker For Cgridview Filter

Hi!

I followed this example: Post

It works the first time, but if after selecting a date I want to choose another date (clcking on filter textbox), the datepicker is not shown again.

Any ideas? Do I have to add a jQuery such as $(’#my_datepicker_textbox’).click(function(){… to reload?

Thanks!

Hi,

Yes you have to use jquery to load it again

add below code in your admin.php file

replace the datefield with your field




'afterAjaxUpdate'=>"function(){jQuery('#datefield').datepicker({'dateFormat': 'yy-mm-dd'})}",  



Great! thank you very much!

where should I place the code? Im a newbie, sorry. Thanks!

Hi. I’ve used it like this:




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

    'id'=>'ticketGridId',

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

    'filter'=>$model,

	'afterAjaxUpdate'=>"function(){

							$.datepicker.setDefaults($.datepicker.regional['en']);

							$('#datepicker_id').datepicker({'dateFormat': 'yy-mm-dd'});

							

						}", 	

	

    'columns'=>array(

		'idTicket',

...



I hope it helps!