我第一次尝试了Kendo自动完成&在配置时遇到了一些问题。
这是代码
$scope.selectOptions = {
placeholder: "Search...",
noDataTemplate: 'No data found',
dataTextField: "Name",
dataValueField: "Id",
valuePrimitive: false,
autoBind: false,
//filter: "contains",
animation: {
close: {
effects: "fadeOut zoom:out",
duration: 300
},
open: {
effects: "fadeIn zoom:in",
duration: 300
}
},
minLength: 3,
dataSource: {
//type: "odata",
serverFiltering: true,
serverPaging: true,
pageSize: 10,
filtering: function (e) {
var filter = e.filter;
if (!filter.value) {
//prevent filtering if the filter does not value
e.preventDefault();
}
},
transport: {
read: {
url: "/Configuration/GetData",
type: 'GET',
dataType: 'json'
},
parameterMap: function (options, type) {
if (type === "read") {
var paramMap = kendo.data.transports.odata.parameterMap(options);
delete paramMap.$inlinecount; // <-- remove inlinecount parameter.
delete paramMap.$format; // <-- remove format parameter.
// return paramMap;
return { searchCriteria: options.filter.filters[0].value};
}
},
schema: {
data: function (data) {
return data; // <-- The result is just the data, it doesn't need to be unpacked.
},
total: function (data) {
return data.length; // <-- The total items count is the data length, there is no .Count to unpack.
}
}
}
}
};
$scope.selectedIds = [1, 2];<select kendo-multi-select k-options="selectOptions" k-ng-model="selectedIds" k-min-length="3" class="form-control"></select>
发布于 2019-09-16 11:03:39
将自动完成的dataSource设置为不从服务器获取任何内容的localDataSource:
const externalDataSource = {...} // what you have now
const localDataSource = new kendo.data.DataSource()
externalDataSource.bind("change", (e) => {
localDataSource.data(e.sender.data())
})
externalDataSource.read()https://stackoverflow.com/questions/57955134
复制相似问题