1
我試圖讓服務器過濾和分頁下拉。分頁工作正常,但是當我開始輸入過濾器時,我的控件會向服務器發送無限次查詢。請幫我配置這個控件。 數據源:KendoUI。下拉式虛擬化無法正常工作
getDataSource = function() {
return new kendo.data.DataSource({
type: "json",
transport: {
read:{
url:"...",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json"
},
parameterMap: function (options, operation) {
switch (operation) {
case "read":
return JSON.stringify(options);
break;
}
}
},
schema: {
data: "Data",
total: "Total",
model: {
id: "Id"
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true
});
}
選項下拉菜單:
$scope.DropDownOptions = {
dataTextField: "Value",
dataValueField: "Id",
dataSource: getDataSource(),
filter: "contains",
virtual: {
itemHeight: 26,
valueMapper: function (options) {
$.ajax({
url: "...",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
skip: 0, pageSize: 20, take: 1, filter: { logic: "and", filters: [{ value: options.value, field: "Value", operator: "contains", ignoreCase: true }] }
}),
success: function (data) {
options.success([]);
}
})
}
},
height: 290,
}
和服務器端:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public DictionaryQueryResponse GetDictionary(KendoUIDropDownRequest request)
{
var response = new DictionaryQueryResponse();
string filterQuery = request.filter.filters[0].value;
var data = _client.GetDictionary(filter: filterQuery, skip: request.skip, take: request.take);
response.Data = data;
response.Total = 1000;
return response;
}
一個更重要的事情: 當我改變 options.success([])來options.success(data.Data),它仍然發送infinit查詢,但除此之外還有第一項中的分層(2個相同的值繪製一個c ontainer)和分頁正在放緩。當我滾動一下列表,分頁正常化