grid.CGridView 0和1转化查询 [ 1.1 版本 ]
controller:
$model=new CompanyVouchers('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['CompanyVouchers'])){
$_GET['CompanyVouchers']['accept']=$_GET['CompanyVouchers']['accept']=='是' ? 1 :($_GET['CompanyVouchers']['accept']== '否' ? 0 : $_GET['CompanyVouchers']['accept']);
$model->attributes=$_GET['CompanyVouchers'];
}
$this->render('index',array(
'model'=>$model,
'id'=>$id,
));
view:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'company-vouchers-grid',
'dataProvider'=>$model->search($id),
'filter'=>$model,
'columns'=>array(
'accept'=>array(
'name'=>'accept',
'value'=>'$data->accept==1 ? "是" : "否"',
'filter'=>CHtml::activeTextField($model,'accept',array('value'=>isset($model->accept)?($model->accept=='1' ? "是":($model->accept=='0' ? "否" : $model->accept)):'')),
),
),
)); ?>
model:
$criteria->compare('t.accept',$this->accept,true);//改为模糊查询
晦涩de咚
注册时间:2015-08-03
最后登录:2020-09-04
在线时长:356小时20分
最后登录:2020-09-04
在线时长:356小时20分
- 粉丝36
- 金钱13598
- 威望340
- 积分20558
共 0 条评论