Kendo UI Excel导出,生成多个文件,刷新不正确吗? [英] Kendo UI Excel export, generating multiple files, not refreshed properly?
问题描述
我有一个单页面应用程序,该应用程序经常从数组中创建新数据
I have a single page app, that often creates new data from an array
var searchData = new kendo.data.DataSource({data:buildData});
var searchData = new kendo.data.DataSource({data: buildData});
然后将其显示在网格中
除了excel导出错误的行为如下所示,其他一切看起来都不错:
this all looks good except the excel export missbehaves as follows:
运行一次搜索,excel导出就可以正常工作.
run one search and the excel export works fine.
运行第二个搜索,然后excel导出下载2个文件,第一个是第一个搜索结果的重复,第二个文件是新搜索.
run a second search and the excel export downloads 2 files, the first being a repeat of the results of the first search, the second file being the new search.
运行第三个搜索,Excel将导出三个文件....依此类推...
run a third search and the excel exports three files.... and so on...
似乎刷新对我不起作用,但我不知道为什么不这样做?
it appears the refresh isn't working for me, but i don't have any idea why not?
if(searchedArray) {
searchedArray.forEach(function (row) {
buildData.push({r:rowCount,w:row['w'],n:'1',nl:'2',o:row['o'],t:row['t'],d:row['d'];
rowCount++;
});
}
var searchData = new kendo.data.DataSource({data: buildData});
var sGrid=null;
sGrid = $("#searchedgrid").kendoGrid({
toolbar: ["excel"],
excel: {
fileName: "filename.xlsx",
proxyURL: "http://demos.telerik.com/kendo-ui/service/export",
filterable: true
},
dataSource: searchData,
sortable: {
mode: "multiple",
allowUnsort: true
},
schema: {
model: {
fields: {
r: { type: "number" },
w: { type: "number" },
n: { type: "string" },
nl: { type: "string" },
o: { type: "string" },
t: { type: "string" },
d: { type: "date" }
}
}
},
height: sHeight,
scrollable: true,
pageable: false,
selectable: "multiple cell",
allowCopy: true,
columns: [
{ field: "r",width: 40,title: "Rank",template:'<center>#=r#</center>'},
{ field: "w",width: 50,title: "Weight",template:'<center>#=w#</center>'},
{ field: "n", title: "Number", width: "80px",template:'<center>#=n#</center>'},
{ field: "nl", title: " ", width: "14px",template:'<center><a href="#=nl#" onclick="javascript:void window.open(\'#=nl#\',\'details\',\'width=800,height=600,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0\');return false;"><div class="ambLink" id="detaillink" title="View details"></div></a></center>',sortable:false},
{ field: "o",width: 200,title: "Owner"},
{ field: "t",width: 400,title: "Title", attributes: {style: 'white-space: nowrap '} },
{ field: "d",width: 70,title: "Filed",template:'<center>#=d#</center>'}
]
}).data("kendoGrid");
$("#searchedgrid").data('kendoGrid').refresh();
推荐答案
通过在选择器之后添加.html(''),它对我有用:
It worked for me by adding the .html('') after the selector:
$("#grid").html('').kendoGrid({
...
});
这篇关于Kendo UI Excel导出,生成多个文件,刷新不正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!