Yii Framework Forum: Unable To Load Date With Cjuidatepicker - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Unable To Load Date With Cjuidatepicker Rate Topic: -----

#1 User is offline   sanjay1024 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 06-October 12

Posted 08 October 2012 - 09:40 PM

Hi,

I am having 3 Date field column in my table. I am using CJuiDatePicker to pick date. It is working in CGridView for all the 3 field but only for the first search and again to load the date picker it is working only for 3rd field (End_Date). i want it to work for other two fields also.

I have done as per below for all my fields DOB, Start_Date & End_Date & .

Below snip from _form.php

<div class="row">
		<?php echo $form->labelEx($model,'Start_Date'); ?>
		<?php      $this->widget('zii.widgets.jui.CJuiDatePicker',       
		array( 'attribute'=>'Start_Date',
				'model'=>$model,
				'options' => array(
									'mode'=>'focus',
									'dateFormat'=>'d MM, yy',
									'showAnim' => 'slideDown',
									),
				'htmlOptions'=>array('size'=>30,'class'=>'date'),
				)    
				);   
		?> 
		<?php echo $form->error($model,'Start_Date'); ?>
	</div>


Below snip from Master.php

protected function beforeSave()   
		{     
		$this->DOB=date('Y-m-d', strtotime(str_replace(",", "", $this->DOB)));
		$this->Start_Date=date('Y-m-d', strtotime(str_replace(",", "", $this->Start_Date)));
		$this->End_Date=date('Y-m-d', strtotime(str_replace(",", "", $this->End_Date)));
		return TRUE;   
		} 



Below snip from admin.php

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'master-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	
	'afterAjaxUpdate'=>"function(){jQuery('#DOB').datepicker({'dateFormat': 'yy-mm-dd'})}", 
	'afterAjaxUpdate'=>"function(){jQuery('#Start_Date').datepicker({'dateFormat': 'yy-mm-dd'})}", 
	'afterAjaxUpdate'=>"function(){jQuery('#End_Date').datepicker({'dateFormat': 'yy-mm-dd'})}", 
	
	'columns'=>array(
                 ........
		
		array('name' => 'DOB', 'type' => 'raw',  'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'DOB', 'htmlOptions' => array('id' => 'DOB'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)),

		array('name' => 'Start_Date', 'type' => 'raw',  'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'Start_Date', 'htmlOptions' => array('id' => 'Start_Date'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)),

		
		array('name' => 'End_Date', 'type' => 'raw',  'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'End_Date', 'htmlOptions' => array('id' => 'End_Date'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)), 



I am also having a field in table which is having date and time but with CJuiDatePicker i am getting only date not time, please help me to get time also in date picker.

I am using yii-1.1.12 version.

Thanks in advance.

Regards
Sanjay
0

#2 User is offline   oxigen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 05-February 09

Posted 09 October 2012 - 01:01 AM

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


Change to:
 'afterAjaxUpdate'=>"function(){jQuery('#DOB').datepicker({'dateFormat': 'yy-mm-dd'});jQuery('#Start_Date').datepicker({'dateFormat': 'yy-mm-dd'});jQuery('#End_Date').datepicker({'dateFormat': 'yy-mm-dd'})}", 

0

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,166
  • Joined: 05-January 12
  • Location:Morocco

Posted 09 October 2012 - 02:20 AM

View Postsanjay1024, on 08 October 2012 - 09:40 PM, said:

I am also having a field in table which is having date and time but with CJuiDatePicker i am getting only date not time, please help me to get time also in date picker.

You have to use some extension, like datetimepicker: http://www.yiiframew...datetimepicker/
0

#4 User is offline   sanjay1024 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 06-October 12

Posted 09 October 2012 - 01:51 PM

Hi Junior Member,

Thanks your solution worked for me. It is working fine as expected.
Thanks a lot.

Hi Master Member,

I went through the link provided by you, but i am unable to understand how to use it.

I have extracted the file in extensions\timepicker\assets\jquery-ui-timepicker-addon.js folder and copied the code to _form view.

<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'model'=>$model, //Model object
        'attribute'=>'nextupdate', //attribute name
                'mode'=>'datetime' //use "time","date" or "datetime" (default)
        'options'=>array() // jquery plugin options
    ));
?>



after adding the code when checked it is throwing error.

Kindly assist me.

Thanks in advance.

Regards
Sanjay
0

#5 User is offline   sanjay1024 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 06-October 12

Posted 10 October 2012 - 04:29 AM

Hi,

I am unable to resolve it can someone please help me.
0

#6 User is offline   sanjay1024 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 06-October 12

Posted 11 October 2012 - 01:03 AM

Hi,

Kindly ignore the request, I have solved it myself.

Thanks for your support
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users