非法字符串偏移量';类别';在Yii2中
我想用Yii2导出我的表。这是我的桌子: 在Kartik Yii2导出中,当作为Excel导出时,我得到非法的字符串偏移量“class”。这是我的密码:非法字符串偏移量';类别';在Yii2中,yii,yii2,kartik-v,Yii,Yii2,Kartik V,我想用Yii2导出我的表。这是我的桌子: 在Kartik Yii2导出中,当作为Excel导出时,我得到非法的字符串偏移量“class”。这是我的密码: <?php use yii\helpers\Html; use kartik\grid\GridView; use yii\widgets\Pjax; use yii\bootstrap\Model; use yii\helpers\Url; use kartik\export\ExportMenu; $this->titl
<?php
use yii\helpers\Html;
use kartik\grid\GridView;
use yii\widgets\Pjax;
use yii\bootstrap\Model;
use yii\helpers\Url;
use kartik\export\ExportMenu;
$this->title = Yii::t('app', 'Pelamar Doktor Berdasarkan Usia');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="temppelamardoktorusia-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<!-- <p>
<?= Html::a(Yii::t('app', 'Create Jumlah Pelamar Doktor'), ['create'], ['class' => 'btn btn-success']) ?>
</p> -->
<?php
$gridColumns = [
['class' => 'yii\grid\SerialColumn'],
'TahunDaftar',
'lessthan25',
'btween25to29',
'btween30to34',
'btween35to39',
'btween40to44',
'btween45to49',
'morethaneqs50',
'NotComplete',
'Total',
['class' => 'yii\grid\ActionColumn'],
];
//Renders a export dropdown menu
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'fontAwesome' => true,
]);
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'exportConfig'=> [
GridView::CSV=>[
'label' => 'CSV',
'icon' => '',
'iconOptions' => '',
'showHeader' => false,
'showPageSummary' => false,
'showFooter' => false,
'showCaption' => false,
'filename' => 'yii',
'alertMsg' => 'created',
'options' => ['title' => 'Semicolon - Separated Values'],
'mime' => 'application/csv',
'config' => [
'colDelimiter' => ";",
'rowDelimiter' => "\r\n",
],
],
],
]); ?>
</div>
结果:字符串偏移量“class”非法。
以下是错误消息:
我做错了什么?
有没有办法解决这个问题?提前感谢您导入了错误的
GridView
更改此项:使用yii\grid\GridView代码>
通过Kartik的:使用Kartik\grid\GridView代码>是的,谢谢你的更正。但代码仍然不起作用。据说字符串偏移量“class”是非法的。我在上面编辑了我的问题我刚刚在上面的问题上发布了错误消息我将您的代码复制到一个新项目中,没有收到任何错误或警告。你能给我们控制器的动作吗?