Kendo Grid 部分列匯出到excel
阿新 • • 發佈:2018-11-21
場景:
在匯出excel時,不需要匯出所有列,部分列不匯出到excel
bizNo不匯出到excel
//點選
<button class="widthnotcertainbutton" data-bind="events: {click:ExportVoucher}">@ResourcesLan.Export</button>
//展示
<div data-role="grid" id="PayConfirmGrid"
data-auto-bind="true"
data-selectable="row"
data-resizable="true"
data-pageable="true"
data-excel="{allPages: true,fileName:'會計憑證'+'.xlsx'}"
data-columns="[{ 'field': 'Seq','title':'Seq', 'width': 120},
{ 'field': 'BizNo','title':'BizNo', 'width': 320},
{ 'field' : 'Debit','title':'Debit','width': 120,},
{ 'field': 'Credit','title':'Credit','width': 120},
{ 'field': 'Account','title':'Account','width': 120},
{ 'field': 'AccountName','title':'AccountName','width': 180},
{ 'field': 'UnitCode1','title':'UnitCode1', 'width' : 180},
{ 'field': 'UnitCode2','title':'UnitCode2','width': 120},
{ 'field': 'UnitCode3','title':'UnitCode3','width': 120},
{ 'field': 'UnitCode4','title':'UnitCode4','width': 120},
{ 'field': 'Notes','title':'Notes','width': 240},
{ 'field': 'DomesticAmount','title':'DomesticAmount','width': 180,attributes:{'class':'right'},'format':'{0:N2}'},
{ 'field': 'Customer_Vendor','title':'Customer_Vendor','width': 180},
{ 'field': 'Cust_num_Vend_num','title':'Cust_num_Vend_num','width': 180},
{ 'field': 'BankCode','title':'BankCode','width': 100},
{ 'field': 'SettleMethod','title':'SettleMethod','width': 120},
{ 'field': 'ChequeNumber','title':'ChequeNumber','width': 180},
{ 'field': 'ChequeDate','title':'ChequeDate','width': 120},
{ 'field': 'CurrencyCode','title':'CurrencyCode','width': 120},
{ 'field': 'ExchangeRate','title':'ExchangeRate','width': 120,attributes:{'class':'right'},'format':'{0:N2}'},
{ 'field': 'ForeignAmount','title':'ForeignAmount','width': 180,attributes:{'class':'right'},'format':'{0:N2}'},
]"
data-bind="source: PayConfirmDatas,events:{change:PayConfirmChange}"
>
</div>
//點選事件
ExportVoucher: function () {
debugger;
//gridexport('PayConfirmGrid');
var grid = $("#PayConfirmGrid").data("kendoGrid");
//var data = this.PayConfirmDatas;
//console.log(grid._data);
//_.each(grid.dataSource.data(), function (t) {
// console.log(t);
// })
grid.hideColumn(1);
grid.saveAsExcel();
}