kartik-v / yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
http://demos.krajee.com/export
Other
165 stars 126 forks source link

export all data table not data shown on grid #350

Closed ry1980 closed 3 years ago

ry1980 commented 3 years ago

i have a form with 2 date field and other 2 field , i take this value to set the query and obtain the dataprovider... the grid shows the correct dataprovider but when i submit the export the file contains all record inside the table on db and not only the record filtered in the dataprovider... how can is it possible?

` public function searchReport($params) { $query = Trattativa::find();

    // add conditions that should always apply here

    $dataProvider = new ActiveDataProvider([
        'query' => $query,
    ]);

    $this->load($params);

    // grid filtering conditions
    $query->andFilterWhere(['between', 'data', $this->date_start,$this->date_end]);

    $query->andFilterWhere(['like', 'tipologia_offerta', $this->offer])
      ->andFilterWhere(['like', 'esito', $this->status]);

    return $dataProvider;
}`

`if(!empty($_POST)){ // $searchModel->load(Yii::$app->request->post()); $dataProvider = $searchModel->searchReport(Yii::$app->request->post());

        return $this->render('report', [
            'model' =>$searchModel,
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }`

in the view ` <?php

    $gridColumns = [
        ['class' => 'kartik\grid\SerialColumn'],

        'tipologia_offerta',
        'stato_offerta',
        'data',
        'esito',

    ];

    echo ExportMenu::widget([
        'dataProvider' => $dataProvider,
        'columns' => $gridColumns,
        'batchSize' => 20,
        'exportConfig' => [
            ExportMenu::FORMAT_TEXT => false,
            ExportMenu::FORMAT_HTML => false,
            ExportMenu::FORMAT_EXCEL => false,
            ExportMenu::FORMAT_PDF => [
                'pdfConfig' => [
                    'methods' => [
                        'SetTitle' => 'Grid Export - Krajee.com',
                        'SetSubject' => 'Generating PDF files via yii2-export extension has never been easy',
                        'SetHeader' => ['Krajee Library Export||Generated On: ' . date("r")],
                        'SetFooter' => ['|Page {PAGENO}|'],
                        'SetAuthor' => 'Kartik Visweswaran',
                        'SetCreator' => 'Kartik Visweswaran',
                        'SetKeywords' => 'Krajee, Yii2, Export, PDF, MPDF, Output, GridView, Grid, yii2-grid, yii2-mpdf, yii2-export',
                    ]
                ]
            ],
        ],
        'dropdownOptions' => [
            'label' => 'Export',
            'class' => 'btn btn-outline-secondary',
            'asDropdown' => false
        ]
    ]);

    echo
    GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => $gridColumns,
    ]);

?>`
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/98600436-export-all-data-table-not-data-shown-on-grid?utm_campaign=plugin&utm_content=tracker%2F7668315&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F7668315&utm_medium=issues&utm_source=github).
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

neoacevedo commented 1 year ago

In the example page, https://demos.krajee.com/export-demo-dtl/grid-basic the menu exports all the data, not only what is showed in the current grid page, but implementing it, the export menu only exports what is in the current page.