2amigos / yii2-grid-view-library

Highly enhanced GridView widget and grid components for Yii2
https://2amigos.us
Other
57 stars 16 forks source link

How can i have action column in Your Grid view #32

Closed miladhashemi closed 7 years ago

miladhashemi commented 7 years ago

How can i have action column in grid view? I use Your GridView+GroupColumnsBehavior Thanks

miladhashemi commented 7 years ago

You develop gridview widget nicely. but DOC isn't clear enough.That's better, if you have more example in DOC. Thank You.

tonydspaniard commented 7 years ago

@miladhashemi you need to know how the Yii2 Gridview works. I highly recommend you to have a look at http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html

miladhashemi commented 7 years ago

I used 'class' => ActionColumn::className(), in gridview columns But it show me this error:

Unknown Property – yii\base\UnknownPropertyException Getting unknown property: yii\grid\ActionColumn::attribute

tonydspaniard commented 7 years ago

@miladhashemi you obviously have missconfiguration of your grid. Do you mind pasting your code so i can see what you doing wrong?

miladhashemi commented 7 years ago

@tonydspaniard Thank You so much.


    <?php
use yii\helpers\Html;
use yii\grid\ActionColumn;

use dosamigos\grid\GridView;
use dosamigos\grid\behaviors\GroupColumnsBehavior;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\advance\models\TargetGroupSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'گروه های هدف';
$this->params['breadcrumbs'][] = $this->title;
?>
    <div class="target-group-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?=
    GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,

    'behaviors' => [
        [
            'class' => GroupColumnsBehavior::class,
            // You an use multiple columns for extra row but remember that will affect the merging
            // as both columns must be having same values for the extra row to title the records
            'extraRowColumns' => ['category'],
            // you can use multiple columns here
            'mergeColumns' => ['category']
        ]
    ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'category',
            'group_name',
            'description',
            ['class' => ActionColumn::class]
        ],
    ]);
?>
    </div>
tonydspaniard commented 7 years ago

@miladhashemi

Apologies, as your code is good. The only thing is that the GroupColumnsBehavior do not work with the ActionColumn.

I will create a new ticket to make this behavior working with ActionColumn. Sorry again.

miladhashemi commented 7 years ago

@tonydspaniard Thank You indeed brother. It has same problem with SerialColumn too. I mean same Error.