kartik dynagrid上的错误

时间:2016-07-14 13:38:04

标签: php yii yii2 yii2-extension

实施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,
             ]
        ]);

?>

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

1 个答案:

答案 0 :(得分:1)

您正在使用较旧版本的dynagrid。更新dynagrid,此错误已得到修复。这是Django REST Framework documentation