2017-04-26 288 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