In Magento 1 I could add export functionality to any admin grid I create by adding this
$this->addExportType('*/*/exportCsv', Mage::helper('helper_alias')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('helper_alias')->__('Excel XML'));
in the _prepareColumns
of the grid block and then implementing the expotCsvAction
and exportXmlAction
in my admin controller.
How can I achieve the same result in Magento 2 in the new grid system? (the one that uses ui components and knockout js for rendering). Example, the products grid, the cms pages grid.
Or better yet, is this even possible?
Best Answer
You can use sales/orders grid as example.
exportButton ui component responsable for UI
where selectProvider is component responsible for selections data.
By default csv/xml options available and leads to \Magento\Ui\Controller\Adminhtml\Export\GridTo{Csv,Xml} action that export all selected data from data provider.