yii2-grid icon indicating copy to clipboard operation
yii2-grid copied to clipboard

ExpandRowColumn child grid not expanding

Open davidpeetoom opened this issue 1 year ago • 0 comments

Prerequisites

  • [x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x ] The issue still exists against the latest master branch of yii2-grid.
  • [x ] This is not an usage question. I confirm having gone through and read the documentation and demos.
  • [x ] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • [x ] I have attempted to find the simplest possible steps to reproduce the issue.
  • [ x] I have included a failing test as a pull request (Optional).

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
  • [ ] The bug happens consistently across all tested browsers
  • [ x] This bug happens when using yii2-grid without other plugins.

davidpeetoom avatar Nov 20 '23 14:11 davidpeetoom