简体   繁体   中英

How to configure TbRelationalColumn with Yii Booster?

I want to implement the extendgridview from yii booster to show the related id from the other table when i click on the table row (TbRelationalColumn).

The documentation frovided on the web site is not sufficent for me to understand how to configure the controler and the model. http://yiibooster.clevertech.biz/extendedGridView#extendedgridview

I have 2 tables: 1 Tours and 1 toursdetails. The pk in table tours is tour_id and the FK in toursdetails is tour_id in my model in tours details i have

  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'),

            );
        }

in my tours controller i have

   $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()
    ));
}

in the view i have

    $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"',

        )
    ),
));

in the view tours/relational i have

<?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',
));

when i implement the solution i get an error , i dont understand how this works , where and how do you set a PK, or i dont know ,, why do i get an error, if you guys need more details please let me know.

In your view tours/relational you call $dataProvider but it is not in the function actionRelational. Yiibooster writes an error if there's something wrong in the view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM