KendoGrid Excel 导出延迟加载的所有页面
KendoGrid Excel export all pages with lazy loading
我的导出 excel 工具栏在我不使用 allPages = true
时效果很好。
使用所有页面选项它不会引发任何错误并且什么也不做,我发现这可能是由于每个页面的延迟加载行造成的。
我搜索了很多,没有找到任何解决这个问题的方法。
<script>
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
serverPaging: true,
serverSorting: true,
serverFiltering: true,
requestEnd: function (e) {
showServerMessageInGrid(e);
if (e.response.IsSuccess == false)
this.read();
},
transport: {
read: {
url: "@Url.Action("AjaxOrderList", "Order")",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation == "read") {
return { options: kendo.stringify(options) };
}
if (operation !== "read") {
return {
models: kendo.stringify(options.models),
options: kendo.stringify(options)
};
}
}
},
batch: true,
pageSize: 20,
schema: {
data: 'ViewModel',
total: 'TotalCount',
model: {
id: "Id",
fields: {
Id: { width: 90, editable: false },
CityName: { width: 120, editable: false }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
toolbar:[{ name: "excel" }],
excel: {
fileName: "OrderList.xlsx",
filterable: true,
allPages: true
},
scrollable:true,
pageable: true,
selectable: true,
resizable: true,
filterable: true,
sortable: true,
columns: [
{ field: "Id", width: "90px", editable: false, filterable: filterableNumeric() },
{ field: "CityName", width: "120px", editable: false }
],
editable: "inline",
}
});
});
</script>
知道如何使用延迟加载导出所有页面吗?
我发现了我的问题。
这是 MaxJsonLength
因为我操作的结果是 new JavaScriptSerializer().Serialize(_orderList).
我通过Int32.MaxValue()
解决了
var json = new JavaScriptSerializer();
json.MaxJsonLength = Int32.MaxValue;
var jsonResult = json.Serialize(_orderList);
return jsonResult;
我的导出 excel 工具栏在我不使用 allPages = true
时效果很好。
使用所有页面选项它不会引发任何错误并且什么也不做,我发现这可能是由于每个页面的延迟加载行造成的。
我搜索了很多,没有找到任何解决这个问题的方法。
<script>
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
serverPaging: true,
serverSorting: true,
serverFiltering: true,
requestEnd: function (e) {
showServerMessageInGrid(e);
if (e.response.IsSuccess == false)
this.read();
},
transport: {
read: {
url: "@Url.Action("AjaxOrderList", "Order")",
dataType: "json",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation == "read") {
return { options: kendo.stringify(options) };
}
if (operation !== "read") {
return {
models: kendo.stringify(options.models),
options: kendo.stringify(options)
};
}
}
},
batch: true,
pageSize: 20,
schema: {
data: 'ViewModel',
total: 'TotalCount',
model: {
id: "Id",
fields: {
Id: { width: 90, editable: false },
CityName: { width: 120, editable: false }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
toolbar:[{ name: "excel" }],
excel: {
fileName: "OrderList.xlsx",
filterable: true,
allPages: true
},
scrollable:true,
pageable: true,
selectable: true,
resizable: true,
filterable: true,
sortable: true,
columns: [
{ field: "Id", width: "90px", editable: false, filterable: filterableNumeric() },
{ field: "CityName", width: "120px", editable: false }
],
editable: "inline",
}
});
});
</script>
知道如何使用延迟加载导出所有页面吗?
我发现了我的问题。
这是 MaxJsonLength
因为我操作的结果是 new JavaScriptSerializer().Serialize(_orderList).
我通过Int32.MaxValue()
var json = new JavaScriptSerializer();
json.MaxJsonLength = Int32.MaxValue;
var jsonResult = json.Serialize(_orderList);
return jsonResult;