Yii 1.0 框架CArrayDataProvider示例代码
$rawData = array(array('id'=>'1'),array('id'=>'2'));
$dataProvider=new CArrayDataProvider($rawData, array(
'keyField'=>'id',
'pagination'=>array(
'pageSize'=>10,
),
));
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'cart-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
array(
'class'=>'CButtonColumn',
'viewButtonUrl'=>'Yii::app()->controller->createUrl("view",array("id"=>$data["id"]))',
'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",array("id"=>$data["id"]))',
'deleteButtonUrl'=>'Yii::app()->controller->createUrl("delete",array("id"=>$data["id"]))',
),
),
));
留言