1

正在实施kartik dynagrid但得到一个错误,只有变量应该被传递。

这是我尝试过的代码:

      <?php
       $columns = [
            'id',
            'username',
            'first_name',
            'other_names',
            'email',
            [
                'class' => ActionColumn::className(),
                'header' => 'Roles',
                'template' => '{assign-roles}',
                'buttons' => [
                    'assign-roles' => function ($url, $model, $key) {

                        return Html::a("Assign Role", $url);
                    }
                ]
            ],
            [
                'class' => ActionColumn::className(),
                'header' => 'Action',
                'buttons'=>[
                    'delete'=>function($url, $model, $key){
                        return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
                            'title' => Yii::t('yii', 'Delete'),
                            'data-confirm' => Yii::t('yii', 'Are you sure to delete this item ?'.
                            'We recommend deactivating the user to avoid inconcistencies with the data this user handled'),
                            'data-method' => 'post',
                        ]);

                    }
                ]
            ]
        ];

这是grid

            echo DynaGrid::widget([
            'columns' => $columns,
            'showPersonalize' => true,
            'options' => ['id' => 'dynagrid-users'],
            'gridOptions' => [
                'dataProvider' => $dataProvider,
                'pager' => [
                    'firstPageLabel' => 'First',
                    'lastPageLabel' => 'Last',
                    'maxButtonCount' => 10,
                ],
                'panel' => [
                    'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> All Users</h3>',
                    'before' =>
                        '<i>* All Users in the database</i><br>',
                    //'after'=>Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['index'], ['class' => 'btn btn-info']),
                    'footer' => true
                ],
                'toolbar' => [
                    ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'],
                    '{export}',
                    '{toggleData}'
                ],
                'pjax' => true,
                'bordered' => true,
                'striped' => true,
                'condensed' => true,
                'responsive' => true,
                'responsiveWrap' => false,
             ]
        ]);

?>

我总是收到只有变量应该通过引用传递的错误。

4

1 回答 1

1

您正在使用旧版本的 dynagrid。更新 dynagrid,这个错误已经修复。这是Github 问题

于 2016-07-14T14:53:28.697 回答