Hi,
I have problem with DatePickers in CGridView filter. There are 3 columns with DatePicker filter. I want it bo be in Polish language and it is. I also need it to have format: yy-mm-dd. Unofortunately it has the format only for the initial request to the page. After ajax update of the CGridView (doesn’t matter if I changed one of datepickers or any other filter) - when I try to change/set date in datepicker it changes the format to dd.mm.yyy. Why? I have javascript function that is being called after ajax update.
Here is the code (part of the CGridView plus the javascript function):
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id'=>'projects-grid',
'type' => 'striped condensed',
'dataProvider'=>$model->search(),
'filter'=>$model,
'afterAjaxUpdate' => 'reinstallDatePicker',
'ajaxUrl' => $this->createUrl('projects/admin'),
'columns'=>array(
array(
'name' => 'idProject',
'htmlOptions' => array('width' => '60px',
'style' => 'text-align: right;',
'class' => 'gridIdColumn'),
),
'name',
array(
'name' => 'projStart',
'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker',
array(
'model' => $model,
'attribute' => 'projStart',
'language' => 'pl',
'htmlOptions' => array(
'id' => 'Projects_projStart',
'dateFormat' => 'yy-mm-dd',
),
'options' => array( // (#3)
'showOn' => 'focus',
'dateFormat' => 'yy-mm-dd',
'showOtherMonths' => true,
'selectOtherMonths' => false,
'changeMonth' => false,
'changeYear' => false,
)
),
true),
),
array(
'name' => 'confirmStart',
'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker',
array( ....
Yii::app()->clientScript->registerScript('re-install-date-picker', "
function reinstallDatePicker() {
$('#Projects_projStart').datepicker($.datepicker.regional[ 'pl' ]);
$('#Projects_projStart').datepicker({dateFormat: 'yy-mm-dd'});
$('#Projects_confirmStart').datepicker($.datepicker.regional[ 'pl' ]);
$('#Projects_presentationDate').datepicker($.datepicker.regional[ 'pl' ]);
}
");
I also use YiiBooster but I don’t think it’s relevant.