I have a custom admin grid, which shows the feedback given by customers during checkout.
I have 19 fields in the custom_table including entity_id, created_at and updated_at.
This is my form view:
This is my grid view:
everything works fine. Now when I export the grid as csv/ xml/ excel, it would only export the fields in the grid, but I want all the data in my database-table to be exported. How can I do that?
Also If i apply filter in that grid, only those rows should be exported.
note: customer name and email_id are displayed by joining the sales/order table
This is my _prepareCollection() function in Grid.php
protected function _prepareCollection(){
$collection = Mage::getModel('feedbacktest/feedback')->getCollection();
// join the order table to display in the grid.
$collection->join('sales/order', 'increment_id=order_id', array('orderId'=>'entity_id', 'custName'=>'concat(customer_firstname," ",customer_lastname)', 'custEmail'=>'customer_email'), null,'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
Collection gives me all the data (as I require), but exported data contains only the data in the grid.
Can someone help me on this?
Best Answer
You can add in your grid columns that are visible only on export.
In the
_prepareColumns()
method add this:Just like any other column, just wrapped in
if ($this->_isExport) {
.