Click here for EduSec Demo EduSec Screenshots

Datepicker in filter Search Box

On 2013-06-10 - By Ravi Thanki

yii framework provider filter seach facility in admin view. if we want add datepicker in filter box to search date in admin view.

Following example demostrate how to used datepicker in filter search box.

array(
‘name’ => ‘date’,
‘value’=>’($data->date == 0000-00-00) ? “Not Set” : date_format(new DateTime($data->date), “d-m-Y”)’,
‘filter’ => $this->widget(‘zii.widgets.jui.CJuiDatePicker’, array(
‘model’ => $model,
‘attribute’ => ‘date’,
‘options’=>array(
‘dateFormat’=>’dd-mm-yy’,
‘changeYear’=>’true’,
‘changeMonth’=>’true’,
‘showAnim’ =>’slide’,
‘yearRange’=>’1900:’.(date(‘Y’)+1),
‘buttonImage’=>Yii::app()->request->baseUrl.’/images/calendar.png’,
),
‘htmlOptions’=>array(
‘id’=>’date’,
),

),
true),
),

‘afterAjaxUpdate’ => ‘reInstallDatepicker’,

function for reinstall datepicker when second time searching

Yii::app()->clientScript->registerScript(‘for-date-picker’,”
function reInstallDatepicker(id, data){
$(‘#academic_term_start_date’).datepicker({‘dateFormat’:'dd-mm-yy’});
$(‘#academic_term_end_date’).datepicker({‘dateFormat’:'dd-mm-yy’});
}
“);