Here’s my code. Some potential points, I’m not sure if I put the right thing in for $dataProvider.
<?Php
use yii\data\SqlDataProvider;
$provider = new SqlDataProvider([
'sql' => "SELECT email,full_name FROM entries WHERE contest_id=$contest_id",
'pagination' => [
'pageSize' => 10,
],
'sort' => [
'attributes' => [
'email',
],
],
]);
// returns an array of data rows
$dataProvider = $provider->getModels();
$gridColumns = [
['class' => 'yii\grid\SerialColumn'],
'full_name',
'email',
['class' => 'yii\grid\ActionColumn'],
];
// Renders a export dropdown menu
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns
]);
// You can choose to render your own GridView separately
echo \kartik\grid\GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns
]);
?>
Here’s the error message:
Invalid Configuration – yii\base\InvalidConfigException
The 'gridview' module MUST be setup in your Yii configuration file and must be an instance of 'kartik\grid\Module'.