jQuery MiniUI
标题:
datagrid导出excel 如何向后台传递参数?
[打印本页]
作者:
haitao
时间:
2013-7-25 09:31:31
标题:
datagrid导出excel 如何向后台传递参数?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="caiwu.aspx.cs" Inherits="users_user" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="
http://www.w3.org/1999/xhtml
">
<head runat="server">
<title>用户管理</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="../demo/demo.css" rel="stylesheet" type="text/css" />
<script src="../scripts/boot.js" type="text/javascript"></script>
<!--引入皮肤样式-->
<link href="../scripts/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style1
{
color: #FF3300;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h1>业余时间来院加班人员登记表 <span class="style1">(财务报表)</span>
<asp:TextBox ID="TextBoxUser" runat="server" Width="0px" BorderStyle="None"
Enabled="False" EnableViewState="False" Height="0px"></asp:TextBox>
<asp:TextBox ID="TextBoxYuanqu" runat="server" Width="0px" BorderStyle="None"
Enabled="False" Height="0px" style="font-size: medium; color: #FF3300"></asp:TextBox>
</h1>
<div style="width:70%;">
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
<table style="width:100%;">
<tr>
<td style="width:100%;">
开始时间<input id="start_time" style="width:150px;" property="editor" class="mini-datepicker" showtime="true" format="yyyy-MM-dd H:mm" />截止时间
<input id="end_time" style="width:150px;" property="editor" class="mini-datepicker" showtime="true" format="yyyy-MM-dd H:mm" />
<a class="mini-button" iconCls="icon-search" plain="true">提取</a>
<span class="separator"></span>
<a class="mini-button" iconCls="icon-downgrade" plain="true">导出EXCEL</a>
<span class="separator"></span>
</td>
</tr>
</table>
</div>
</div>
<div id="datagrid1" class="mini-datagrid" style="width:70%;height:280px;"
url="StaffService.aspx?method=GetShenheByDate" idfileld="id" allowResize="false" pageSize="20"
allowCellEdit="true" allowCellSelect="true" multiSelect="false" allowRowSelect="true"
>
<div property="columns">
<div field="dept" name="dept" allowResize="false" width="20" headerAlign="center" allowSort="true">科室
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="staff_id" name = "staff_id" allowResize="false" width="10" headerAlign="center" allowSort="true">工号
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="staff_name" name="staff_name" allowResize="false" width="10" headerAlign="center" allowSort="true">姓名
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="grade" name="grade" width="10" headerAlign="center" >职称
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="fee_kind" name="fee_kind" width="18" headerAlign="center" >标准(小时/元)
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="sum_work" name="work_hour" width="18" headerAlign="center" >总时间(小时)
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
<div field="fee_sum" name="fee_sum" width="18" headerAlign="center" >金额(元)
<input property="editor" class="mini-textbox" style="width:100%;" />
</div>
</div>
</div>
</form>
<iframe id="exportIFrame" style="display:none;"></iframe>
<!--导出Excel相关HTML-->
<form id="excelForm" action="export.aspx?type=excel" method="post" target="excelIFrame">
<input type="hidden" name="columns" id="excelData" />
</form>
<iframe id="excelIFrame" name="excelIFrame" style="display:none;"></iframe>
<script type="text/javascript">
mini.parse();
var txtUser = document.all.TextBoxUser.value;
var txtYuanqu = document.all.TextBoxYuanqu.value;
var grid = mini.get("datagrid1");
function retrieve() {
var d1 = mini.get("start_time");
var d2 = mini.get("end_time");
grid.on("load", function () {
grid.mergeColumns(["dept"]);
});
grid.load({ start_time: mini.formatDate(d1.value, "yyyy-MM-dd HH:mm:ss"), end_time: mini.formatDate(d2.value, "yyyy-MM-dd HH:mm:ss") });
}
function ExportExcel() {
var columns = grid.getBottomColumns();
function getColumns(columns) {
columns = columns.clone();
for (var i = columns.length - 1; i >= 0; i--) {
var column = columns
;
if (!column.field) {
columns.removeAt(i);
} else {
var c = { header: column.header, field: column.field };
columns
= c;
}
}
return columns;
}
var columns = getColumns(columns);
var json = mini.encode(columns);
document.getElementById("excelData").value = json;
var excelForm = document.getElementById("excelForm");
excelForm.submit();
}
</script>
<div class="description">
<h3>操作说明</h3>
<ul>
<li>按时间段提取审核签字后的加班记录</li>
<li>报表可以通过导出EXCEL功能进行保存并打印</li>
</ul>
<p>
</p>
</div>
</body>
</html>
-----------------------------------------------
以上是我的查询代码,需要传入两个时间参数,我提取没有问题,但是导出excel时总是取不到时间参数,不知道该在什么地方赋值?
请教,非常感谢!
作者:
haitao
时间:
2013-7-25 13:53:33
找到办法了,呵呵
var d1 = mini.get("start_time");
var d2 = mini.get("end_time");
var d_start = mini.formatDate(d1.value, "yyyy-MM-dd HH:mm:ss");
var d_end = mini.formatDate(d2.value, "yyyy-MM-dd HH:mm:ss")
excelForm.action = "export.aspx?type=excel&start_time=" + d_start + "&end_time=" + d_end;
excelForm.submit();
作者:
felt
时间:
2013-7-25 14:59:07
给力的大牛
作者:
star
时间:
2014-6-3 18:10:47
felt 发表于 2013-7-25 14:59
给力的大牛
如果我需要传比较长的参数 中间有 空格 & ? 等呢 怎么传url直接截断呀
作者:
factory
时间:
2014-6-4 09:38:34
star 发表于 2014-6-3 18:10
如果我需要传比较长的参数 中间有 空格 & ? 等呢 怎么传url直接截断呀
url带参有长度限制.
如果过长的内容,用ajax或者其他方式传
欢迎光临 jQuery MiniUI (http://miniui.com/discuss/)
Powered by Discuz! X2