2017 © Pedro Peláez
 

yii2-extension yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

image

dimmitri/yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

  • Sunday, April 1, 2018
  • by dimmitri
  • Repository
  • 2 Watchers
  • 3 Stars
  • 301 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 31 % Grown

The README.md

Expand row column for the Yii 2.0 GridView widget

Displays a clickable column that will make an ajax request and display its resulting data into a new row., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist dimmitri/yii2-expand-row-column "*"

or add, (*4)

"dimmitri/yii2-expand-row-column": "*"

to the require section of your composer.json file., (*5)

Usage

Prior to version 1.0.5, the 'column_id' property was generated automatically. In version 1.0.5, it is now possible to assign the 'column_id' property. Assigning the 'column_id' property is optional, but recommended., (*6)

Example, (*7)

view/index.php:, (*8)


= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => SerialColumn::class], // simple example [ 'class' => ExpandRowColumn::class, 'attribute' => 'name', 'column_id' => 'column-info', 'url' => Url::to(['info']), ], // advanced example [ 'class' => ExpandRowColumn::class, 'attribute' => 'status_id', 'column_id' => 'column-status', 'ajaxErrorMessage' => 'Oops', 'ajaxMethod' => 'GET', 'url' => Url::to(['detail']), 'submitData' => function ($model, $key, $index) { return ['id' => $model->status_id, 'advanced' => true]; }, 'enableCache' => false, 'afterValue' => function ($model, $key, $index) { return ' ' . Html::a( Html::tag('span', '', ['class' => 'glyphicon glyphicon-download', 'aria-hidden' => 'true']), ['csv', 'ref' => $model->status_id], ['title' => 'Download event history in csv format.'] ); }, 'format' => 'raw', 'expandableOptions' => [ 'title' => 'Click me!', 'class' => 'my-expand', ], 'contentOptions' => [ 'style' => 'display: flex; justify-content: space-between;', ], ], ['class' => ActionColumn::class], ], ]) ?>

Actions:, (*9)

public function actionIndex()
{
    $searchModel = new ModelSearch();
    $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
//  The key (or keyField) must be filled, if the key is not equal to primary key.        
    $dataProvider->key = 'uuid';// for ActiveDataProvider 
//  $dataProvider->keyField = 'uuid';// for ArrayDataProvider 

    return $this->render('index', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
    ]);
}

public function actionDetail($id, $advanced = false)
{
    $model = $this->findModel($id);

    $dataProvider = new ArrayDataProvider([
        'allModels' => $model->events,
    ]);

    return $this->renderAjax('_detail', [
        'dataProvider' => $dataProvider,
        'advanced' => $advanced,
        'id' => $id,
    ]);
}

view/_detail.php:, (*10)


"pjax-{$id}", 'enablePushState' => false]); ?> = GridView::widget([ // .... ]) ?>

The Versions

01/04 2018

dev-master

9999999-dev https://github.com/dimmitri/yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

  Sources   Download

MIT

The Requires

 

yii2 widget grid

03/03 2018

v1.0.2

1.0.2.0 https://github.com/dimmitri/yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

  Sources   Download

MIT

The Requires

 

yii2 widget grid

27/06 2017

v1.0.1

1.0.1.0 https://github.com/dimmitri/yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

  Sources   Download

MIT

The Requires

 

yii2 widget grid

27/06 2017

v1.0.0

1.0.0.0 https://github.com/dimmitri/yii2-expand-row-column

Expand row column for the Yii 2.0 GridView widget.

  Sources   Download

MIT

The Requires

 

yii2 widget grid