PansyNguyen
(Hoangnguyenletran)
June 14, 2010, 11:07am
1
Hi guys,
I’m working with CGridView to display a data list as a table. In table header, CGridView supports filter as an input or drop down list. But my data list has date column and I’d like to filter by date. I use extension SCalendar to display calendar by overwrite function renderFilterCellContent() of CDataColumn. However, I have 2 problems need your help:
How can call ajax after select a date by calendar automatically?
When I input date in input textbox, the filter works but after that, script to run js calendar dies. The calendar cannot show again by clicking the button of calendar.
mpluss
(Mahdi Mastouri)
October 19, 2010, 9:03am
2
Hello PansyNguyen,
Have you found a solution? I have the same problem .
Thank you.
mpluss
(Mahdi Mastouri)
October 20, 2010, 9:41am
3
Here is the solution :
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'facture-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'FullNumFact',
array('name'=>'DateFact',
'value'=>'$data->DateFact',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'DateFact','language'=>'fr'), true),
),
),
'afterAjaxUpdate'=>'function(){
jQuery("#'.CHtml::activeId($model, 'DateFact').'").datepicker({ });
$.datepicker.setDefaults($.datepicker.regional["fr"]);
}',
));
GSTAR
(Omzy83)
October 20, 2010, 11:27am
4
It doesn’t display for me. Are there any additional JS files included when you insert the DatePicker widget?
mpluss
(Mahdi Mastouri)
October 20, 2010, 12:04pm
5
I think these two libraries are sufficient:
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerCoreScript('jquery.ui');
and the localization file (FR) : http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-fr.js
Manjula
(Manjula B)
October 20, 2010, 12:28pm
6
Hi everyone i have data in the $contents, so now i want those values to be displayed in the CGridView. Can anyone help on this how to assign to columns r dataprovider?
Thanks in advance
larry1
(Info)
November 2, 2010, 8:00pm
7
Have you tried removeing the other jquery stuff from the page?
For me, the advance search stuff on the admin view was conflicting. I removed that and now the date picker works.
Only issue is, I can’t have an empty value in there. It’s defaulting to 1969.
Arthur
(Ya Alfred)
January 4, 2011, 8:21pm
8
Is anyone have an idea how to use it with CListView?
netyum
(Netyum)
April 22, 2011, 9:44am
9
nayjest
(Mail)
April 22, 2011, 12:45pm
10
I seen extenstion that adds calendar as filter, you can use it, or learn, how it works, but it’s code isn’t very clean: sydatecolumn
linares82
(Fillinares)
July 15, 2013, 11:52pm
11
Hi everybody, I discover a little diference to do it works: take a look in afterAjaxUpdate and filter in the array defaultOptions
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'tbl-precios-grid',
'dataProvider'=>$m_precios->search(),
'filter'=>$m_precios,
'afterAjaxUpdate'=>'function(){
jQuery("#'.CHtml::activeId($m_precios, 'ini_vigencia').'").datepicker({ });
$.datepicker.setDefaults($.datepicker.regional["es"]);
}',
'columns'=>array(
//'ini_vigencia',
array('name'=>'ini_vigencia',
'value'=>'$data->ini_vigencia',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker',
array('model'=>$m_precios,
'attribute'=>'ini_vigencia',
'language'=>'es',
'defaultOptions'=>array(
'autoSize'=>true,
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
'duration'=>'fast',
'buttonImage'=>Yii::app()->baseUrl.'/images/calendar.png',
'selectOtherMonths'=>true,
'showButtonPanel'=>true,
'showOn'=>'button',
'showOtherMonths'=>true,
'changeMonth'=>true,
'changeYear'=>true,
),
),
true),
),
array(
'class'=>'CButtonColumn',
),
));
?>
sukunj
(Mendparasukunj27)
July 16, 2013, 9:52am
12
Hi guys,
I’m working with CGridView to display a data list as a table. In table header, CGridView supports filter as an input or drop down list. But my data list has date column and I’d like to filter by date. I use extension SCalendar to display calendar by overwrite function renderFilterCellContent() of CDataColumn. However, I have 2 problems need your help:
How can call ajax after select a date by calendar automatically?
When I input date in input textbox, the filter works but after that, script to run js calendar dies. The calendar cannot show again by clicking the button of calendar.
Try this :
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' => 'academic_term_start_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),
),