剑道UI自动完成数据源读取运输只有一次 [英] Kendo UI AutoComplete datasource transport reads only once
问题描述
我变得疯狂的剑道UI自动完成组件。我用我自己的函数使用jQuery来访问数据,所以我必须设置自动完成dataSource.transport.read为函数。在code是这样的。
I'm becoming crazy with Kendo UI AutoComplete component. I'm using my own functions to access data with jQuery, so I have to set the AutoComplete dataSource.transport.read as a function. The code is something like this.
minLengthAtocomplete = 3;
$('#autocomplete').kendoAutoComplete({
minLength : 3,
filter : "contains",
dataValueField : "key",
dataTextField : "value",
dataSource : new kendo.data.DataSource({
transport : {
read : _OnTransportRead
},
schema : {
/* object schema */
}
})
});
function _OnTransportRead(e) {
var text = $.trim(e.data.filter.filters[0].value);
if (text && text.length >= minLengthAtocomplete) {
_GetUsers(
text,
function onSuccess(data) {
var users = [];
/* sets users with info in data */
e.success(users);
},
function onError(error) {
/* stuff with error */
}
);
}
}
function _GetUsers(userName, onSuccess, onError) {
/* Ajax to get users from DB */
}
这code完美运行,但 dataSource.transport.read 只调用了一次。我的文字的michae的第一搜索和自动完成组件运行其dataSource.transport.read预期。然后,我添加了一个以上的字母来搜索的'迈克尔'的,并且dataSource.transport.read永远不会再次调用。就是这么折腾!
This code runs perfectly, but dataSource.transport.read is called only the once. I do a first search with the text 'michae' and AutoComplete component runs its dataSource.transport.read as expected. Then, I add a one more letter to search for 'michael', and dataSource.transport.read is never called again. Is so frustrating!
我试图使用自动同步数据源属性,手动同步数据源,在数据绑定自动完成设置新的数据源对象,但没有运气。
I tried using autoSync dataSource property, manual dataSource Sync, set new dataSource objects on AutoComplete dataBound, but no luck.
我是什么做错了吗?什么我忘了?
What am I doing wrong? What am I forgetting?
先谢谢了。
推荐答案
您应该启用<一个href=\"http://docs.kendoui.com/api/framework/datasource#serverfiltering%20booleandefault\">serverFiltering为了使数据源每次提出要求。
You should enable serverFiltering in order for the data source to make requests every time.
$('#autocomplete').kendoAutoComplete({
minLength : 3,
filter : "contains",
dataValueField : "key",
dataTextField : "value",
dataSource : new kendo.data.DataSource({,
serverFiltering: true,
transport : {
read : _OnTransportRead
},
schema : {
/* object schema */
}
})
});
这篇关于剑道UI自动完成数据源读取运输只有一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!