0
votes

Trying to set up kratik grid export in Yii after doing everything I keep getting

Call to undefined method app\models\User::instance()

here is my code

$exportedValues = [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'deduction_date'], ['attribute' => 'deduction_amount'], ['attribute' => 'deduction_remark'], ['class' => 'kartik\\grid\\ActionColumn']];
$export = ExportMenu::widget(['dataProvider' => $dataProvider, 'columns' => $exportedValues, 'noExportColumns' => [0, 3], 'columnSelectorOptions' => ['label' => 'Columns', 'class' => 'btn btn-danger'], 'target' => '_blank', 'fontAwesome' => true, 'dropdownOptions' => ['label' => 'Export', 'class' => 'btn btn-success']]);

  echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 
  'columns' => [['class' => 'yii\\grid\\SerialColumn'], 
  'first_name', 'last_name', 'email_id', 'phone', ['class' => 'yii\\grid\\ActionColumn']]]); ?>
2
What is your Yii 2 version? - rob006

2 Answers

0
votes

Try to install kartik, or check your kartik version

php composer.phar require kartik-v/yii2-widgets "*"

0
votes

Had the same issue. on the source code of ExportMenu.php I replaced:

$model = $modelClass::instance();

by:

$model = new $modelClass;

solved it for me.