Closed aiddroid closed 5 years ago
Export menu extension will export all rows by default (not current page).
You may want to elaborate with config and code details to reproduce what issue you are facing...
@kartik-v I am also getting this issue. The 'Full' export seems to be working ok, but the 'Page' export has some funny business going on.
Please could you shed some light on this?
For example, when I click on JSON:
Then I get this error:
My code:
$fullExportMenu = ExportMenu::widget([
'dataProvider' => $provider,
'clearBuffers' => true,
'columns' => $gridColumns,
'target' => '_self',
'exportConfig' => [
ExportMenu::FORMAT_CSV => [],
ExportMenu::FORMAT_HTML=> [],
ExportMenu::FORMAT_TEXT => [],
ExportMenu::FORMAT_PDF => [],
ExportMenu::FORMAT_EXCEL => false,
ExportMenu::FORMAT_EXCEL_X => [],
],
'fontAwesome' => true,
'dropdownOptions' => [
'label' => 'Full',
'class' => 'btn btn-default',
'itemsBefore' => [
'<li class="dropdown-header">Export All Data</li>',
],
],
]);
echo GridView::widget([
'dataProvider' => $provider,
'columns' => $gridColumns,
'pjax' => false,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> Library</h3>',
],
'export' => [
'label' => 'Page',
'fontAwesome' => true,
],
'toolbar' => [
'{export}',
$fullExportMenu,
['content'=>
Html::button('<i class="glyphicon glyphicon-plus"></i>', [
'type'=>'button',
'title'=>Yii::t('kvgrid', 'Add Book'),
'class'=>'btn btn-success'
]) . ' '.
Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['grid-demo'], [
'data-pjax'=>0,
'class' => 'btn btn-default',
'title'=>Yii::t('kvgrid', 'Reset Grid')
])
],
]
]);
@kartik-v it seems to me that the defaults for the grid export are not functioning correctly, at least in my case. The export menu config seems to be working, so what I'd like to do is somehow replicate that config for the grid. I have tried testing adding 'exportConfig' for just CSV to the gridview as follows to see if it works as follows:
echo GridView::widget([
'dataProvider' => $provider,
'columns' => $gridColumns,
'pjax' => false,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> Library</h3>',
],
'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",
],
],
],
'export' => [
'label' => 'Page',
'fontAwesome' => true,
],
'toolbar' => [
'{export}',
$fullExportMenu,
['content'=>
Html::button('<i class="glyphicon glyphicon-plus"></i>', [
'type'=>'button',
'title'=>Yii::t('kvgrid', 'Add Book'),
'class'=>'btn btn-success'
]) . ' '.
Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['grid-demo'], [
'data-pjax'=>0,
'class' => 'btn btn-default',
'title'=>Yii::t('kvgrid', 'Reset Grid')
])
],
]
]);
But when I do so I get the following error:
Can you spot something that I'm doing wrong? I would really appreciate some guidance on this.
@Kreat1vK0dr your question is related to yii2-grid extension and not yii2-export?
Secondly, your parameters are shown up as tampered... ensure you have the latest release of the extension (yii2-grid) and the latest javascript/assets being loaded on your client. Ensure your cache is clean and web assets/runtime folder are cleaned/reset on web server - to ensure you do not have stale/old assets running.
@kartik-v I do realise that. I came across this issue and related to it so I responded accordingly. Would you like to carry on this thread on yii2-grid issues instead?
While you're thinking about that, let me respond to your other comments.
I installed the grid view about two days ago by adding the following to my composer.json file:
"kartik-v/yii2-grid": "@dev"
Surely this should have the latest release of the extension? Secondly, which javascript/assets are you referring to? I did not read that I require additional assets beyond installing the grid view?
An aside: I have a question relating to the validity and process of styling the pdf document with css - since I don't want to annoy you any further by posting unrelated questions here, and that this query is not really an issue - what would be an appropriate communication method of discussing this? Should I open a new issue even though it isn't one, or do you have an email address to which I can send the query?
The yii2-grid extension has its own assets (javascript) which should get loaded in your client and which is important for the behavior of the export and such functionality. Even if you have updated the extension - the browser cache (and / or yii2's own file cache) may be loading old stale assets (depending on your environment/app config).
Where are these assets of which you speak? Am I supposed to load them manually?
They are loaded automatically by Yii2's asset manager component. You may want to read about Yii2 asset handling in Yii2 docs.
i have problem.
my code echo AppealTabs::widget(); if($dataProvider->totalCount > 0){ echo ExportMenu::widget([ 'dataProvider' => $dataProvider, 'columns' => $gridColumns, 'filename' => 'exported-data', 'showConfirmAlert' => true, 'target' => ExportMenu::TARGET_SELF, 'fontAwesome' => true, 'dropdownOptions' => [ 'label' => 'Export All', 'class' => 'btn btn-outline-secondary', 'itemsBefore' => [ '
Cannot export current page data now?I have followed the instruction from page(http://demos.krajee.com/export-demo-dtl/grid-advanced-1) but nothing happend