Closed indigitale closed 7 years ago
Share your code on how you have setup Dynagrid...
This is my code:
<?php
/* @var $this yii\web\View */
/* @var $searchModel app\models\RegistrobanchidicollaudoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
use yii\widgets\Pjax;
use yii\helpers\Html;
use kartik\export\ExportMenu;
use kartik\dynagrid\DynaGrid;
use kartik\grid\GridView;
use mdm\admin\components\Helper;
use yii\bootstrap\Modal;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
if (Helper::checkRoute('delete')) {
echo Html::a(Yii::t('rbac-admin', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('rbac-admin', 'Are you sure to delete this item?'),
'data-method' => 'post',
]);
}
$this->title = 'Registro Banchi di Collaudo';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="registrobanchidicollaudo-index">
<?php
$gridColumns = [
['class' => 'kartik\grid\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT],
['attribute' => 'id', 'visible' => false],
[
'label' => 'Funzione Del Banco',
'attribute' => 'funzione_del_banco',
'noWrap' => true,
],
'NOTE',
[
'class' => 'kartik\grid\ActionColumn',
'visible' => (Yii::$app->user->can("crea-labmetro-banchi")),
'options' => ['width' => '120'],
],
];
$fullExportMenu = ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'target' => ExportMenu::TARGET_BLANK,
'fontAwesome' => true,
'pjaxContainerId' => 'kv-pjax-container',
'dropdownOptions' => [
'label' => 'Esporta',
'class' => 'btn btn-default',
'itemsBefore' => [
'<li class="dropdown-header">Export All Data</li>',
],
],
]);
?>
<?php
echo DynaGrid::widget([
'columns' => $gridColumns,
'storage' => DynaGrid::TYPE_COOKIE,
'gridOptions' => [
'dataProvider' => $dataProvider,
'condensed' => true,
'hover' => true,
'pjax' => true,
'pjaxSettings' => ['options' => ['id' => 'kv-pjax-container-registrobanchidicollaudo']],
'resizableColumns' => true,
'exportConfig' => [
GridView::EXCEL => [
'linkOptions' => [],
'mime' => 'application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'extension' => 'xlsx',
'writer' => 'Excel2007'
],
GridView::PDF => [],
],
'resizeStorageKey' => Yii::$app->user->id . '-' . date("m"),
// 'floatHeader'=>true,
// 'perfectScrollbar' => true,
'filterModel' => $searchModel,
'panel' => ['heading' => '<h3 class="panel-title">Registro Banchi di Collaudo</h3>',
'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> Crea Nuovo', ['create'], ['class' => 'btn btn-success']),
],
'toolbar' => [
['content' =>
Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid'])
],
['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'],
#'{export}',
$fullExportMenu,
]
],
'options' => ['id' => 'dynagrid-1'] // a unique identifier is important
]);
?>
</div>
and this is my config:
'modules' => [
'dynagrid'=> [
'class'=>'\kartik\dynagrid\Module',
],
'gridview'=> [
'class'=>'\kartik\grid\Module',
],
.......
Ok, the problem is:
$fullExportMenu = ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'target' => ExportMenu::TARGET_BLANK,
'fontAwesome' => true,
'pjaxContainerId' => 'kv-pjax-container',
'dropdownOptions' => [
'label' => 'Esporta',
'class' => 'btn btn-default',
'itemsBefore' => [
'<li class="dropdown-header">Export All Data</li>',
],
],
]);
but, what is my mistake?
Hi, you put 'order' in dynagrid, but not in ExportMenu
Yes as @metola said.
The order
property is only valid for columns config in DynaGrid extension. It is not valid for columns in GridView or ExportMenu. Set your columns correctly.
I encountered the same problem,thanks
Go to FrontEnd or BackEnd open config folder and choose main.php and past it given code 'modules' => [ 'gridview' => [ 'class' => '\kartik\grid\Module', ], ],
Hi all,
if i add the order property, ['class'=>'kartik\grid\SerialColumn', 'order'=>DynaGrid::ORDER_FIX_LEFT], i receive this error: "Setting unknown property: kartik\grid\SerialColumn::order" I have latest version of Gridview and Dynagrid. In debug i have:
`exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: kartik\grid\SerialColumn::order' in /var/www/ybase/vendor/yiisoft/yii2/base/Object.php:161 Stack trace:
0 /var/www/ybase/vendor/yiisoft/yii2/BaseYii.php(525): yii\base\Object->__set('order', 'fixleft')
1 /var/www/ybase/vendor/yiisoft/yii2/base/Object.php(105): yii\BaseYii::configure(Object(kartik\grid\SerialColumn), Array)
2 [internal function]: yii\base\Object->__construct(Array)
3 /var/www/ybase/vendor/yiisoft/yii2/di/Container.php(381): ReflectionClass->newInstanceArgs(Array)
4 /var/www/ybase/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('kartik\grid\Ser...', Array, Array)
5 /var/www/ybase/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container->get('kartik\grid\Ser...', Array, Array)
6 /var/www/ybase/vendor/yiisoft/yii2/grid/GridView.php(534): yii\BaseYii::createObject(Array)
7 /var/www/ybase/vendor/yiisoft/yii2/grid/GridView.php(278): yii\grid\GridView->initColumns()
8 /var/www/ybase/vendor/kartik-v/yii2-grid/GridView.php(942): yii\grid\GridView->init()
9 /var/www/ybase/vendor/kartik-v/yii2-export/ExportMenu.php(726): kartik\grid\GridView->init()
10 /var/www/ybase/vendor/yiisoft/yii2/base/Object.php(107): kartik\export\ExportMenu->init()
11 [internal function]: yii\base\Object->__construct(Array)
12 /var/www/ybase/vendor/yiisoft/yii2/di/Container.php(381): ReflectionClass->newInstanceArgs(Array)
13 /var/www/ybase/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('kartik\export\E...', Array, Array)
14 /var/www/ybase/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container->get('kartik\export\E...', Array, Array)
15 /var/www/ybase/vendor/yiisoft/yii2/base/Widget.php(136): yii\BaseYii::createObject(Array)
16 /var/www/ybase/frontend/views/registrobanchidicollaudo/index.php(178): yii\base\Widget::widget(Array)
17 /var/www/ybase/vendor/yiisoft/yii2/base/View.php(328): require('/var/www/ybase/...')
18 /var/www/ybase/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('/var/www/ybase/...', Array)
19 /var/www/ybase/vendor/yiisoft/yii2/base/View.php(152): yii\base\View->renderFile('/var/www/ybase/...', Array, Object(frontend\controllers\RegistrobanchidicollaudoController))
20 /var/www/ybase/vendor/yiisoft/yii2/base/Controller.php(381): yii\base\View->render('index', Array, Object(frontend\controllers\RegistrobanchidicollaudoController))
21 /var/www/ybase/frontend/controllers/RegistrobanchidicollaudoController.php(41): yii\base\Controller->render('index', Array)
22 [internal function]: frontend\controllers\RegistrobanchidicollaudoController->actionIndex()
23 /var/www/ybase/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
24 /var/www/ybase/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
25 /var/www/ybase/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('', Array)
26 /var/www/ybase/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('registrobanchid...', Array)
27 /var/www/ybase/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
28 /var/www/ybase/frontend/web/index.php(17): yii\base\Application->run()
29 {main}`
Can you help me? Thanks!