我试图在 CGridView 中包含一个 Datepicker,如下所示,datepicker 小部件在网格视图中使用。
this->widget('zii.widgets.grid.CGridView', array(
'id'=>'order-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'order_id',
'customer.address.firstname',
'customer.address.lastname',
/*array('name' => 'ordering_date',
'value' => 'date("M j, Y", $data->ordering_date)'),
*/
array('name'=>'ordering_date',
'value'=>'$data->ordering_date',
'filter'=>$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'ordering_date',
'options'=>array(
'showButtonPanel'=>true,
'changeYear'=>true,
)
),
true),
'htmlOptions'=>array('width'=>'80','style'=>'text-align:center'),
),
array(
'class'=>'CButtonColumn',
'template' => '{view} {rollback} {receive}{pack} {dispatch}{delivered}',
'htmlOptions'=>array('width'=>'250px'),
'buttons'=>array(
'receive'=>array(
'id'=>'receive',
'name'=>'receive',
'url'=>'$this->grid->controller->createUrl("/shop/order/admin&received=true", array("id"=>$data->order_id,"asDialog"=>1,"gridId"=>$this->grid->id))',
'type'=>'submit',
'imageUrl'=>'/mdg/images/Receive1.png',
'visible'=>'($data->status=="pending")?true:false;'
),
'pack'=>array(
'id'=>'pack',
'name'=>'pack',
'type'=>'submit',
'url'=>'$this->grid->controller->createUrl("/shop/order/admin&packed=true", array("id"=>$data->order_id,"asDialog"=>1,"gridId"=>$this->grid->id))',
'click'=>'',
'imageUrl'=>'/mdg/images/pack1.png',
'visible'=>'($data->status=="received")?true:false;'
),
'dispatch'=>array(
'id'=>'dispatch',
'name'=>'dispatch',
'url'=>'$this->grid->controller->createUrl("/shop/order/admin&dispatched=true", array("id"=>$data->order_id,"asDialog"=>1,"gridId"=>$this->grid->id))',
'click'=>'',
'imageUrl'=>'/mdg/images/dispatch.png',
'visible'=>'($data->status=="packed")?true:false;'
),
'delivered'=>array(
'id'=>'delivered',
'name'=>'delivered',
'url'=>'',
'click'=>'',
'imageUrl'=>'/mdg/images/delivered1.png',
'visible'=>'($data->status=="dispatched")?true:false;'
),
'rollback'=>array(
'id'=>'rollback',
'name'=>'rollback',
'url'=>'$this->grid->controller->createUrl("/shop/order/admin&rollback=true", array("id"=>$data->order_id,"asDialog"=>1,"gridId"=>$this->grid->id))',
'click'=>'',
'imageUrl'=>'/mdg/images/rollback.jpg',
'visible'=>'($data->status=="pending")?false:true;'
),
),
),
'status',
),
'afterAjaxUpdate'=>'function(){
jQuery("#'.CHtml::activeId($model, 'ordering_date').'").datepicker({showButtonPanel:true, changeYear:true});
}',
)); ?>
此代码取自 yiiframework 论坛中给出的建议。但它什么也没做。
知道为什么吗?谢谢!