- 注册时间
- 2014-5-12
- 最后登录
- 2014-6-7
- 阅读权限
- 10
- 积分
- 60
- 精华
- 0
- 帖子
- 10
|
factory 发表于 2014-5-13 16:51
success里面执行页面跳转,不跳转?
success里面是可以跳转 , 但是具体我不知道要跳转到哪里, 如果 我写
"../data/export.aspx?type=excel&searchtable=" + pageData.tableName + "&sortOrder=" + pageData.orderby;
这个地址是访问export.aspx(应该是生成excel的,不是很清楚),但是 这样我就不能把clumns 传进去 ,会出错,现在最关键的是 success如何获取 excel的 具体下载地址 (.xls 后缀),我直接跳转就可以了
全部代码都贴出来了 - function toExcel() {
- //导出excel表传递参数tableName
- loading();
- var tableName = pageData.tableName;
- var sortOrder = pageData.orderby;
- //$("#excelForm").attr("action", "..\\data\\export.aspx?type=excel&searchtable=" + tableName + "&sortOrder=" + sortOrder);
- var columns = grid.getBottomColumns();
- function getColumns(columns) {
- columns = columns.clone();
- for (var i = columns.length - 1; i >= 0; i--) {
- var column = columns[i];
- if (!column.field) {
- columns.removeAt(i);
- } else {
- var c = { header: column.header, field: column.field };
- columns[i] = c;
- }
- }
- return columns;
- }
- var columns = getColumns(columns);
- var json = mini.encode(columns);
- document.getElementById("excelData").value = json;
- var excelForm = document.getElementById("excelForm");
- //excelForm.submit();
- //提交表单数据
- var form = new mini.Form("#excelForm");
- $.ajax({
- url: "../data/export.aspx?type=excel&searchtable=" + tableName + "&sortOrder=" + sortOrder,
- type: "post",
- data: { columns: json },
- success: function (text) {
- stoploading();
- window.location.href = "../data/export.aspx?type=excel&searchtable=" + pageData.tableName + "&sortOrder=" + pageData.orderby;
- }
- });
- function loading() {
- mini.mask({
- el: document.body,
- cls: 'mini-mask-loading',
- html: '加载中...'
- });
- }
- function stoploading() {
- mini.unmask(document.body);
- }
- }
- function close(action) {
- if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
- else window.close();
- }
- function refresh() {
- grid.reload();
- }
复制代码 |
|