主要代码:
array( 'class'=>'CLinkColumn',
'header'=>'订单编号',//显示表的列名称
'labelExpression'=>'$data->orders_sn',//显示字段名称
'urlExpression'=>'Yii::app()->createUrl("admin/tblOrderDetial/listDetial",array("orders_id"=>$data->orders_id))',//显示URL
'linkHtmlOptions'=>array('title'=>'See all entries with this last name')
),
实现效果:
点击订单编号为:140319-8966的项目,跟转到该订单编号对应的详细商品清单:
views/admin.php的代码
<?php
/* @var $this TblOrdersController */
/* @var $model TblOrders */
$this->breadcrumbs=array(
'Tbl Orders'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'订单列表', 'url'=>array('index')),
array('label'=>'增加订单', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#tbl-orders-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>管理订单</h1>
<p>
注:使用搜索时,可以输入 (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) 查询特定条件的记录。
</p>
<?php echo CHtml::link('高级搜索','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'tbl-orders-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'orders_id',
//'orders_sn',
array( 'class'=>'CLinkColumn',
'header'=>'订单编号',//显示表的列名称
'labelExpression'=>'$data->orders_sn',//显示字段名称
'urlExpression'=>'Yii::app()->createUrl("admin/tblOrderDetial/listDetial",array("orders_id"=>$data->orders_id))',//显示URL
'linkHtmlOptions'=>array('title'=>'See all entries with this last name')
),
'members_id',
'orders_status',
'shipping_status',
'consignee',
/*
'country',
'province',
'city',
'address',
'tel',
'mobile',
'email',
'shipping_id',
'shipping_name',
'pay_id',
'pay_name',
'goods_amount',
'add_time',
'confirm_time',
'pay_time',
'shipping_time',
'pay_status',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>