I use kartik widget(ExportMenu) in Yii2. But I have very much data. I can not download data. help to find alternative variation ExportMenu - yii2

echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
]);
please help to find alternative export menu

Try with batch export. See the link or example below - https://demos.krajee.com/export-demo-dtl/batch-loading
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'batchSize' => 10,
'target' => '_blank',
])

Related

Yii2 Gridview display all columns

How can I display all columns in gridview without define the columns that I want to displau in view ?
In Yii2 doc,
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [ //define columns here
'id',
'name',
'created_at:datetime',
// ...
],
]) ?>
Can we just
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => '*',
]) ?>
I don't think there is such a wildcard, but you can use attributes() method on your model (if you have an instance) or array_keys(Model::getTableSchema()->columns);

Yii2 Linkpager can pagination like this

How can I pagination like this with yii 2 framework, demo on page https://laravel-tricks.com/
resource: https://www.yiiframework.com/doc/api/2.0/yii-widgets-linkpager
This is easy just increase number of maxButtonCount. Here is example:
This is GridView.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pager' => [
'maxButtonCount'=>40, // Set maximum number of page buttons that can be displayed
],
'columns' => [ ....
These is LinkPager.
echo LinkPager::widget([
'pagination' => $pagination,
'maxButtonCount'=>40,
.....
]);

in yii2, yii\grid\ActionColumn class giving empty column at all tables in a database

I am using gridview , It is showing action column empty. it is not showing icon for edit, delete, view. can any one tell what is problem??
here is code
<?php
$gridColumns = [
[
'class' => 'yii\grid\SerialColumn',
],
'id',
'name',
'created',
'modified',
'modified_by_id',
['class' => 'yii\grid\ActionColumn'],
]; ?>
<?php
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'filterModel'=>$searchModel,
'columns' => $gridColumns,
'columnSelectorMenuOptions' =>
[
'style'=> 'overflow-y: scroll, height: auto;
max-height: 300px; overflow-x: hidden;',
],
'target' => ExportMenu::TARGET_SELF ,
]);
?>
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
]);
?>
You need to add something like this:
['class' => 'yii\grid\ActionColumn',
'template' => '{delete}',
]
the "delete" should be your action name in the controller.
I found solution...In vendor folder actioncolumn.php file a line was commented ..thats why it Was showing blank column

How to hide rows from Yii2 GridView based on user permissions?

I'm trying to hide rows from a GridView based on user permissions (RBAC).
(Yii::$app->user->can('readModel', ['model' => $model]);)
I assumed i have to add some filters to the search model, but i can't find out how i can add this filter to the query.
Maybe there is an easier solution that i haven't found yet, like adding an argument to the GridView call?
Docs don't really help me understand this specific situation either.
Thanks in advance.
a way clould be based on assign a proper class to rows using row options
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
.........
['class' => 'yii\grid\ActionColumn'],
],
'rowOptions'=>function ($model){
$class= (Yii::$app->user->can('readModel', ['model' => $model]) ? 'hide' : 'swow';
return $class;
},
As suggest the plurality of the attribute "rowOptions" is an array, lamba-function should return an array:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
.........
['class' => 'yii\grid\ActionColumn'],
],
'rowOptions'=>function ($model){
$class= (Yii::$app->user->can('readModel', ['model' => $model]) ? 'hide' : 'swow';
// HTML tag attribute class
return ['class' => $class];
},

Yii2 - Search link in the gridview not working

In my yii2 project, I'm using Pjax GridView.
My index page:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'batch',
[
'attribute' => 'file_import',
'format' => 'raw',
'value'=>function ($data) {
return Html::a($data->file_import, ['/device/index', 'DeviceSearch', 'batch' => $data->batch]);
},
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
The link in the file_import column goes to http://localhost/index.php/device/index?1=DeviceSearch&batch=200325806610154437. But in this url, all the data is showing instead of showing only the search result. I wanted to set the file_import column as an url which will show only the search result by the provided parameter in the url.
Thank you in advance.
Change URL route to
['/device/index', 'DeviceSearch[batch]' => $data->batch]