Filter CGridView with dateStart and dateEnd
#1
Posted 16 May 2010 - 05:01 AM
I've created a CGridView using 1.1.2 yiic console (very nice, indeed) and it display something like 00-00-0000 00:00 in dateStart and dateEnd columns, in the row where filters are. Now I would like to improve that, using a date picker. Any suggestion?
TIA
Danilo
#2
Posted 19 October 2010 - 03:51 AM
Have you found a solution? I have the same problem
Thank you.
#3
Posted 19 October 2010 - 06:31 AM
You can set it in items:
items=>array(
dateStart=>array(
[...]
'filter'=>$this->widget('CJuiDatepicker'),
),
),
#4
Posted 19 October 2010 - 07:01 AM
<?php $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('CJuiDatepicker'),
),
),
)); ?>
But it does not work, Here is the error :
CJuiDatePicker must specify "model" and "attribute" or "name" property values.
#5
Posted 19 October 2010 - 07:15 AM
zaccaria, on 19 October 2010 - 06:31 AM, said:
You can set it in items:
items=>array(
dateStart=>array(
[...]
'filter'=>$this->widget('CJuiDatepicker'),
),
),
'items' or 'columns'? I tried it like this:
'columns'=>array(
array(
'name'=>'register_date',
'value'=>'$data->RegisterDate',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'register_date')),
),
),
But then I get an error: Object of class CJuiDatePicker could not be converted to string
in the renderFilterCellContent() function of CDataColumn.php.
#6
Posted 19 October 2010 - 08:01 AM
try with:
'columns'=>array(
array(
'name'=>'register_date',
'value'=>'$data->RegisterDate',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'register_date'), true),
),
),The fourth parameter should capture the output and return the html.
#7
Posted 19 October 2010 - 08:07 AM
#8
Posted 19 October 2010 - 08:13 AM
I guess that you should write some javascript for make the validation happen at the selection of the date.
#9
Posted 19 October 2010 - 08:21 AM
The calendar does the search the first time, but later it doesn't work anymore. The only solution here is to work without the widget, inlcude manually Jquery-ui javascript and CSS and call Jquery.datepicker manually.
#10
Posted 19 October 2010 - 08:50 AM
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'town-description-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'afterAjaxUpdate'=>"function(){jQuery('#".CHtml::activeId($model, 'town_id')."').datepicker([])}",
'columns'=>array(
array(
'name'=>'town_id',
'value'=>'$data->town->recordDescription',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'town_id'), true),
),
'title',
'description',
array(
'class'=>'CButtonColumn',
),
),
)); ?>We have to specify the filter as CJuiDatepicker, and it is working only the first time.
In order to make it work after ajaxUpdate, we have to set the property afterAjaxUpdate.
Hope this helps
#11
Posted 19 October 2010 - 09:22 AM
d(a).zIndex is not a function
The file is : localhost/test/assets/b466101/jui/js/jquery-ui.min.js
#12
Posted 19 October 2010 - 09:29 AM
Try updating the framework, maybe they fixed it.
#16
Posted 19 October 2010 - 10:34 AM
$.param.querystring is not a function
File "jquery.yiigridview.js" line 146 :
options.url = $.param.querystring(options.url, options.data);
#17
Posted 20 October 2010 - 01:14 AM
Such a huge number of different behavior, really no idea of what can be.
#18
Posted 20 October 2010 - 02:29 AM
#19
Posted 20 October 2010 - 04:35 AM
I did the update of the framework, but the file versions of jquery remain the same, so I used this statement to replace them with the latest versions ( Jquery 1.4.2 and Jquery UI 1.7.1 ) and it works well.
$cs=Yii::app()->clientScript;
$cs->scriptMap=array(
'jquery.js'=>Yii::app()->request->baseUrl.'/js/jquery-1.4.3.min.js',
'jquery-ui-1.7.1.custom.min.js'=>Yii::app()->request->baseUrl.'/js/jquery-ui-1.8.5.custom.min.js',
);
Thank you for all.
#20
Posted 20 October 2010 - 04:54 AM

Help














