kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
557 stars 302 forks source link

ExpandRowColumn child grid not expanding #1081

Open davidpeetoom opened 1 year ago

davidpeetoom commented 1 year ago

Prerequisites

Steps to reproduce the issue

  1. write the following code in a yii2 view:
    
    $models1 = [['id' => 1, 'name' => 'test 1 level 1', 'level' => 1], ['id' => 2, 'name' => 'test 2 level 1', 'level' => 1]];

$models2 = [['id' => 3, 'name' => 'test 3 level 2', 'level' => 2], ['id' => 4, 'name' => 'test 4 level 2', 'level' => 2]];

$dataProvider1 = new \yii\data\ArrayDataProvider(['allModels' => $models1]); $dataProvider2 = new \yii\data\ArrayDataProvider(['allModels' => $models2]);

echo GridView::widget([ 'dataProvider' => $dataProvider1, 'columns' => [ 'id', 'name', 'level', [ 'columnKey' => uniqid(), 'class' => \kartik\grid\ExpandRowColumn::class, 'value' => function ($model, $key, $index, $column) { return \kartik\grid\GridView::ROW_COLLAPSED; }, 'detail' => function ($model, $key, $index, $column) use ($dataProvider2) { return \kartik\grid\GridView::widget([ 'dataProvider' => $dataProvider2, 'columns' => [ 'id', 'name', 'level', [ 'columnKey' => uniqid(), 'class' => \kartik\grid\ExpandRowColumn::class, 'value' => function ($model, $key, $index, $column) { return \kartik\grid\GridView::ROW_COLLAPSED; }, 'detail' => function ($model, $key, $index, $column) { return 'Extra row'; }, ], ], ]); }, ], ], ]);



## Expected behavior and actual behavior

The first gridview expands correctly, but the second one does not. The buttons are not working.

## Environment

#### Browsers

- [ x] Google Chrome
- [ ] Mozilla Firefox
- [ ] Internet Explorer
- [ ] Safari

#### Operating System

- [x ] Windows
- [ ] Mac OS X
- [ ] Linux
- [ ] Mobile

#### Libraries

- jQuery version: 3.6
- yii2-grid version: 3.5.3

## Isolating the problem

- [ ] This bug happens [on the demos page](https://demos.krajee.com/grid-demo)
- [ ] The bug happens consistently across all tested browsers
- [ x] This bug happens when using yii2-grid without other plugins.