【问题标题】:How to configure TbRelationalColumn with Yii Booster?如何使用 Yii Booster 配置 TbRelationalColumn?
【发布时间】: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


    【解决方案1】:

    在您的视图 tours/relational 中,您调用了 $dataProvider,但它不在函数 actionRelational 中。如果视图有问题,Yiibooster 会写一个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 2015-02-24
      • 1970-01-01
      相关资源
      最近更新 更多