1.最终效果
2.html部分
找到:\app\design\adminhtml\default\default\template\widget\grid\container.phtml文件。
写如下代码:
<div class="content-header">
<table cellspacing="0">
<tr>
<td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
<?php
/*2015年6月9日*/
/*因为container.phtml是公共的phtml。下面判断是保证新加的html只出现在sales_order这个控制器下(也就是order列表才出现)*/
$controllerName = $this->getRequest()->getControllerName();
if($controllerName == 'sales_order'):
?>
<td>
<form action="<?php echo $this->getUrl('*/Sales_Order/export') ?>" method="get">
<?php echo $this->getBlockHtml('formkey')?><!--form表单这个不能少-->
日期:<input type="date" name="created" id="created" required="required" placeholder="2015-06-01"/>
<button type="submit" id="send" >导出订单</button>
</form>
</td>
<?php endif;?>
<td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
</tr>
</table>
</div>
<div>
<?php echo $this->getGridHtml() ?>
</div>
3.控制器处理业务部分
\app\code\core\Mage\Adminhtml\controllers\Sales\OrderController.php里 做数据查询,最后导出。
注意上面表单请求的方法是
*/Sales_Order/export, * 号表单当前模块(后台模块、前台模块)
对应OrderController.php里的方法就应该是:public function exportAction(){}