<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'material-logs-grid',
'dataProvider'=>$materialLogSearch->search(),
'filter'=>$materialLogSearch,
'ajaxUpdate'=> true,
'columns'=>array(
'po_number',
'qty_ordered',
array(
'name'=>'price',
'value'=>'number_format($data->price,2)',
'type'=>'raw'
),
array(
'name'=>'price',
'header'=>'Amount',
'value'=>'number_format($data->price*$data->qty_ordered,2)',
'type'=>'raw'
),
'date_ordered',
'note',
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
'buttons'=>array(
'update'=>array(
'options'=>array(
'id'=>"myID-$data->idMaterial_logs",
),
),
),
'updateButtonUrl'=>"Yii::app()->createUrl(\"materialLogs/update\",array(\"id\"=>\$data->idMaterial_logs,\"pid\"=>\"$project_details->idProject\",\"mid\"=>\$data->idMaterials))",
'deleteButtonUrl'=>'Yii::app()->createUrl("/materialLogs/delete",array("id"=>$data->idMaterial_logs))',
),
),
));
?>
我得到这个错误添加在CButtonColumn ID属性不工作
Undefined variable: data
在此行中出现的错误:
'id'=>"myID-$data->idMaterial_logs",
什么是正确的方式来添加一个ID属性在CButtonColumn?我只是想要更新按钮有一个自定义的ID与它的相应的ID是从我的数据库($data->idMaterials
);
因此,例如: 该ID应该是“myID-1”,1有idMaterial_logs的值,这就是为什么我使用$ data-> idMaterial_logs,在这种情况下它不起作用。
我们将非常感谢您的帮助和奖励!谢谢! :)
myID的问题 – Vainglory07
你想让id如何?样品? –
@ bool.dev id应该是“myID-1”,1有idMaterial_logs的值,这就是为什么我使用$ data-> idMaterial_logs,在这种情况下它不起作用。 – PinoyStackOverflower