CJuiDatepicker结合filter模糊查询一天时间的数据 [ 1.1 版本 ]
controller:转化将时间转化为时间戳
if(isset($_GET['CompanyVouchers'])){
$_GET['CompanyVouchers']['giveTime']=isset($_GET['CompanyVouchers']['giveTime'])?strtotime($_GET['CompanyVouchers']['giveTime']):'';
$model->attributes=$_GET['CompanyVouchers'];
}
model:增加查询区间
$criteria->compare('giveTime',">=".($this->giveTime));
$criteria->compare('giveTime',"<".((int)$this->giveTime+86400));
view:时间戳转化为时间
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'company-vouchers-grid',
'dataProvider'=>$model->search($id),
'filter'=>$model,
'afterAjaxUpdate' => 'reinstallDatePicker',
'columns'=>array(
array('name' => 'giveTime','value'=>'$data->giveTime!=0?date("Y-m-d H:i:s","$data->giveTime"):" "', 'type' => 'raw', 'filter'=>$this->widget('zii.widgets.jui.CJuiDatePicker', array('model'=>$model, 'attribute'=>'giveTime', 'htmlOptions' => array('id' => 'datepicker_for_due_date','value'=>isset($model->giveTime) ? $model->giveTime!=null?date('Y-m-d',$model->giveTime): '' : '',), 'options' => array('dateFormat' =>
'yy-mm-dd')), true)),
),
));
Yii::app()->clientScript->registerScript('re-install-date-picker', "
function reinstallDatePicker(id, data) {
$('#datepicker_for_due_date').datepicker
();
}
");
?>
晦涩de咚
注册时间:2015-08-03
最后登录:2020-09-04
在线时长:356小时20分
最后登录:2020-09-04
在线时长:356小时20分
- 粉丝36
- 金钱13598
- 威望340
- 积分20558
共 0 条评论