2016-12-06 55 views
1

當我不使用allPages = true時,我的導出excel工具欄效果很好。 與所有頁面選項它不會引發任何錯誤,什麼也不做,我想通過延遲加載每個頁面的行可能會導致這種情況。KendoGrid 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> 

任何想法如何導出所有頁面的延遲加載?

+0

可能不相關,但你爲什麼要重新閱讀requestEnd的數據源?通過「無所事事」,你是否確實意味着它什麼也不做,或者沒有結果被返回...... devtools作爲請求/響應顯示什麼? AjaxOrderList的服務器實現是什麼? –

回答

0

我發現我的問題。 這是MaxJsonLength,因爲我的行爲的結果是new JavaScriptSerializer().Serialize(_orderList).

我解決它通過Int32.MaxValue()

var json = new JavaScriptSerializer(); 
      json.MaxJsonLength = Int32.MaxValue; 
      var jsonResult = json.Serialize(_orderList); 
      return jsonResult;