KendoGrid Excel导出所有延迟加载的页面

时间:2016-12-06 09:58:48

标签: kendo-ui kendo-grid export-to-excel

当我不使用allPages = true时,我的导出Excel工具栏效果很好。 使用所有页面选项它不会引发任何错误并且什么都不做,我发现这可能是由于每个页面的延迟加载行造成的。

我经常搜索,没有发现任何问题。

<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>

任何想法如何导出延迟加载的所有页面?

1 个答案:

答案 0 :(得分:0)

我发现了我的问题。 它是MaxJsonLength,因为我的操作结果是new JavaScriptSerializer().Serialize(_orderList).

我通过Int32.MaxValue()

解决了这个问题
  var json = new JavaScriptSerializer();
            json.MaxJsonLength = Int32.MaxValue; 
            var jsonResult = json.Serialize(_orderList);
            return jsonResult;