Frage

I am trying to Export the AdminHtml Grids to the CSV. I have foud two methods getCsv() and getCsvFile() for Exporting results grid into CSV file. Could you please anyone tell me what is the difference between these two functions?

Method -1

$fileName = "filename.csv";
$content    = $this->getLayout()->createBlock('custom_modelue/adminhtml_report_grid')
            ->getCsv();
$this->_prepareDownloadResponse($fileName, $content);

Method -2

$fileName = "filename.csv";
$content    = $this->getLayout()->createBlock('custom_modelue/adminhtml_report_grid')
            ->getCsvFile();
$this->_prepareDownloadResponse($fileName, $content);

When i use Method -1 The Filters not get applied for the Export CSV Results. But in Method -2, The Filters are aplied to the resultset.

War es hilfreich?

Lösung

There difference between getCsv() and getCsvFile() is below

get CsvFile() is 

     Retrieve a file container array by grid data as CSV

     Return array with keys type and value

     return array

getcsvFile used to export grid contain to an csv in magen to system in most of cases

  and getCsv() is 
    Retrieve Grid data as CSV
    and return string

Andere Tipps

These are different functions, but with quite similar result.

getCsv() is defined at Mage\Adminhtml\Block\Report\Grid.php

getCsvFile() is defined at Mage\Adminhtml\Block\Widget\Grid.php

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top