Kendo ui 肯杜伊。下拉菜单的虚拟化不需要';我不能正常工作
我正在尝试通过服务器过滤和分页来实现下拉列表。分页工作正常,但当我开始键入filter时,我的控件会向服务器发送无穷多个查询。请帮助我配置此控件。 数据源:Kendo ui 肯杜伊。下拉菜单的虚拟化不需要';我不能正常工作,kendo-ui,dropdown,Kendo Ui,Dropdown,我正在尝试通过服务器过滤和分页来实现下拉列表。分页工作正常,但当我开始键入filter时,我的控件会向服务器发送无穷多个查询。请帮助我配置此控件。 数据源: getDataSource = function () { return new kendo.data.DataSource({ type: "json", transport: { read:{ url:
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),它仍然发送无穷多个查询,但除此之外,在第一项中存在分层(在一个容器中绘制两个相同的值),分页速度正在减慢。当我稍微滚动列表时,分页正常化了,问题解决了。这种奇怪的行为是由 答复:总数=1000;
我需要在这个字段中写下数据库中的实际计数,问题解决了。这种奇怪的行为是由 答复:总数=1000; 我需要在这个字段中写下数据库中的实际计数