- 注册时间
- 2019-5-23
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 76
- 精华
- 0
- 帖子
- 0
|
function ExportExcel() {
var columns = grid.columns;
function getColumns(columns) {
var cols = [];
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var col = { header: column.header, field: column.field, type: column.type };
if (column.columns) {
col.columns = getColumns(column.columns);
}
cols.push(col);
}
return cols;
}
var columns = getColumns(columns);
DownLoad("export.aspx", { type: "excel", columns: columns }, function () {
//alert("导出成功");
});
}
function DownLoad(url, fields, callback) {
//创建Form
var submitfrm = document.createElement("form");
submitfrm.action = url;
submitfrm.method = "post";
submitfrm.target = "_blank";
document.body.appendChild(submitfrm);
if (fields) {
for (var p in fields) {
var input = mini.append(submitfrm, "<input type='hidden' name='" + p + "'>");
var v = fields[p];
if (typeof v != "string") v = mini.encode(v);
input.value = v;
}
}
submitfrm.submit();
setTimeout(function () {
submitfrm.parentNode.removeChild(submitfrm);
if (callback) callback();
}, 1000);
}
|
|