2017-04-26 290 views
0

我已經實現了一個可以填充10,000條記錄的kendo combox控件。在表單加載期間以及在選擇comboxbox查看列表時存在延遲。解決這個性能問題的最佳方法是什麼?如果你注意到,級聯功能是爲這個組合實現的。它根據另一個組合的國家/地區代碼值進行過濾。mvc kendo組合框加載很慢

劍道組合

<div class="form-group"> 
       @Html.LabelFor(model => model.Name1, htmlAttributes: new { @class = "control-label col-md-4" }) 

       <div class="col-md-8"> 
        <div class="editor-field"> 
         @(Html.Kendo().ComboBoxFor(model => model.CustomerMasterDataId) 

       .HtmlAttributes(new { style = "width:100%" }) 
       .DataTextField("CustomerNumberName") 
       .Placeholder("Select...") 
       .DataValueField("CustomerMasterDataId") 
       .Filter("contains") 
       .MinLength(3) 
       .DataSource(dataSource => dataSource 
         .Read(read => 
         { 
          read.Action("RequestHeader_CustomerData", "Request") 
           .Type(HttpVerbs.Post) 
           .Data("GetSalesOfficeFilter"); 
         }).ServerFiltering(true) 
           ).CascadeFrom("CountryCode").Filter("contains") 

        .Events(e => 
        { 
         e.Change("onCustomerComboChange"); 
        }) 
         ) 
        </div> 
        @Html.ValidationMessageFor(model => model.Name1, "", new { @class = "text-danger" }) 
       </div> 

電腦板代碼

public ActionResult RequestHeader_CustomerData(string id) 
     { 
      var response = requestRepository.GetCustomerData(id).AsQueryable().ProjectTo<CustomerViewModel>(); 

      var jsonResult = Json(response, JsonRequestBehavior.AllowGet); 
      jsonResult.MaxJsonLength = int.MaxValue; 
      return jsonResult; 
     } 

回答

1

你也許發送所有記錄到客戶端 - 開發人員使用的工具看JSON的有效載荷。我沒有看到任何標準傳遞給你的動作,所以如果有任何過濾正在進行,它正在完成客戶端(但我不熟悉Kendo ServerFiltering)。

+0

服務器過濾將是限制從服務器返回的項目數的好方法。 [Here](http://demos.telerik.com/kendo-ui/combobox/serverfiltering)是組合框服務器端過濾功能演示的鏈接。 – Sandman