用easyui怎么实现其datagird导出到Excel
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用easyui怎么实现其datagird导出到Excel相关的知识,希望对你有一定的参考价值。
参考技术A 用easyui实现datagird导出到Excel的方法://导出Excel
function exportExcel()
var rows = $("#saleGrid").datagrid("getRows");
for (var i = 0; i < rows.length; i++) //进行数据处理
if (isArray(rows[i].OrganizedId))
rows[i].OrganizedId = rows[i].OrganizedId[0];
if (isArray(rows[i].CustomerId))
rows[i].CustomerId = rows[i].CustomerId[0];
if (rows[i].AdvanceDate != null)
var unix = rows[i].AdvanceDate.replace("/Date(", "").replace(")/", "");
var un = unix.substring(0, 10);
var newDate = new Date();
newDate.setTime(un * 1000);
rows[i].AdvanceDate = newDate.toLocaleString();
if (rows[i].OrderDate != null)
var unix = rows[i].OrderDate.replace("/Date(", "").replace(")/", "");
var un = unix.substring(0, 10);
var newDate = new Date();
newDate.setTime(un * 1000);
rows[i].OrderDate = newDate.toLocaleString();
if (rows[i].RetainageDate != null)
var unix = rows[i].RetainageDate.replace("/Date(", "").replace(")/", "");
var un = unix.substring(0, 10);
var newDate = new Date();
newDate.setTime(un * 1000);
rows[i].RetainageDate = newDate.toLocaleString();
//移除不要的字段
delete rows[i].SaleAtts;
delete rows[i].SaleOrderId;
delete rows[i].SaleOrderItems;
delete rows[i].SaleStatus;
delete rows[i].UserName;
delete rows[i].Customer;
delete rows[i].AddDate;
var bodyData = JSON.stringify(rows); //转成json字符串
//替换中文标题
var a = bodyData.replace(/SaleOrderNo/g, "订单编号").replace(/OrderType/g, "订单类型").replace(/FromWhere/g, "订单来源")
.replace(/OrganizedId/g, "机构").replace(/SaleUser/g, "销售员").replace(/SaleTc/g, "销售提成").replace(/OrderDate/g, '订单日期')
.replace(/ContractNo/g, "合同编号").replace(/Amount/g, "总额").replace(/Advance/g, "首付款").replace(/AdvanceDate/g, "首付款日期")
.replace(/PayMethod/g, "支付方式").replace(/Retainage/g, "尾款").replace(/RetainageDate/g, "尾款日期").replace(/InlayPrice/g, "镶嵌款")
.replace(/CustManager/g, "客户经理").replace(/EquityNo/g, "认股书编号").replace(/LogisticsTotal/g, "物流费用")
.replace(/Remarks/g, "备注").replace(/CompletedStatus/g, "状态").replace(/CustomerId/g, "终端客户");
var postData =
data: a
;
$.ajax(
type: "POST",
url: "ExportExcel",
data: postData,
success: function (data)
if (data == "1")
layer.msg("操作成功,文件在桌面!",
icon: 6,
time: 2000,
);
else if (data == "-1")
layer.msg("操作失败!", icon: 2 );
);
easyui datagird 如何实现单元格中的combobox禁用
var ed = $('#dg').datagrid('getEditor', index:editIndex,field:'productid');
$(ed.target).combobox(disabled: true);
ed对象是个下拉列表框,为什么这个不起作用,如果要禁用combobox的话要怎么做
使用javascript创建combobox
cc" name="dept" value="aa">
$('#cc').combobox(
url:'combobox_data.json',
valueField:'id',
textField:'text'
);
json数据转换示例:
[
"id":1,
"text":"text1"
,
"id":2,
"text":"text2"
,
"id":3,
"text":"text3",
"selected":true
,
"id":4,
"text":"text4"
,
"id":5,
"text":"text5"
] 参考技术B 字面看来好像没什么错误,你试试这样呢
$(ed.target).combobox("disable");追问
谢谢!但还是不行
$(ed.target).combobox("disabled");
$(ed.target).combobox("disable");
$(ed.target).attr(disabled: true);
$(ed.target).attr("disabled",true);
这些都试过了 ,还是不行!还有什么更好的解决方案吗?
那你有报错吗,ed.target取到的是什么元素,可以让我看下吗?表面看不错什么错误
追问不好意思! 因其他事情当误了。
在我查看元素的时候,发现combobox已禁用只不过经过操作过后又还原了!
所以以上方法应该还是正确地,谢谢你!
以上是关于用easyui怎么实现其datagird导出到Excel的主要内容,如果未能解决你的问题,请参考以下文章