【发布时间】:2015-06-05 08:13:34
【问题描述】:
当我点击表格行 (TbRelationalColumn) 时,我想实现来自 yii 助推器的 extendgridview 以显示来自另一个表格的相关 id。
网站上提供的文档不足以让我了解如何配置控制器和模型。 http://yiibooster.clevertech.biz/extendedGridView#extendedgridview
我有 2 个表:1 个 Tours 和 1 个 toursdetails。 table tours 中的 pk 是 tour_id,toursdetails 中的 FK 是 tour_id 在我的旅游细节模型中,我有
public function relations() {
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'tours' => array(self::BELONGS_TO, 'tours', 'tour_id'),
);
}
在我的旅行控制器中,我有
$criteria = 'guide_id=' . Yii::app()->user->id;
$dataProvider = new CActiveDataProvider('Toursextra', array(
'criteria' => array(
'condition' => $criteria,
'order' => 'date ASC',
),
));
public function actionRelational()
{
// partially rendering "_relational" view
$this->renderPartial('_relational', array(
'id' => Yii::app()->getRequest()->getParam('id'),
'gridDataProvider' => $this->getGridDataProvider(),
'gridColumns' => $this->getGridColumns()
));
}
在我看来
$this->widget('booster.widgets.TbExtendedGridView', array(
'type'=>'striped bordered',
'dataProvider' => $dataProvider,
'template' => "{items}",
'columns' => array(
array(
'class'=>'booster.widgets.TbRelationalColumn',
'name' => 'count',
'url' => $this->createUrl('tours/relational'),
'value'=> '"test-subgrid"',
)
),
));
在视图旅游/关系我有
<?php
echo CHtml::tag('h3',array(),'RELATIONAL DATA EXAMPLE ROW : "'.$id.'"');
$this->widget('booster.widgets.TbExtendedGridView', array(
'type'=>'striped bordered',
'dataProvider' => $dataProvider,
'template' => "{items}",
'columns' => 'money',
));
当我实施解决方案时出现错误,我不明白这是如何工作的,您在哪里以及如何设置 PK,或者我不知道,为什么会出现错误,如果你们需要更多详细信息,请让我知道。
【问题讨论】:
标签: php yii yii-extensions