Reputation: 573
I've got a problem with Kendo AutoComplete. I have a form with a few fields on which I'd like to apply the AutoComplete Widget. Some of these fields are dynamically created after the user makes some action.
Here's what I did :
function myAutoComplete() {
$("input.autocomplete").each(function() {
//...Some code...
//Kendo AutoComplete
$(this).kendoAutoComplete({
//Data
dataSource: new kendo.data.DataSource({
//URL
transport: {
read: {
url : "utils/autocomplete.php",
data : {case: acCase, ent: $(prefixTarget + ' input[id*="entreprise_id"]').val()},
cache : false
}
},
schema: {
data: "data"
}
}),
select: function(e){
var dataItem = this.dataItem(e.item.index());
switch (acCase) {
case 1 :
$(prefixTarget + ' input[id*="'+selectorTarget+'"]').val(dataItem.CLI_NUM);
break;
case 2 :
$(prefixTarget + ' input[id*="'+selectorTarget+'"]').val(dataItem.ENT_NUM);
break;
case 3 :
$(prefixTarget + ' input[id*="'+selectorTarget+'"]').val(dataItem.SUC_NUM);
break;
case 4 :
$(prefixTarget + ' input[id*="'+selectorTarget+'"]').val(dataItem.id);
break;
}
},
filter: "contains",
highlightFirst: true,
suggest: true,
dataTextField: "SearchField"
//End Kendo AutoComplete
});
//End each
});
//End function
};
This function is called when the document is ready or when a new element is created. Everything works fine!
I noticed that the dataSource is only called once, when the user types something in a field for the first time. What I'd like to do is call the "dataSource" each time the user enters in a field because some of the data passed in the "transport" might have been changed. In a way, I just want to call my file named "autocomplete.php" again to make a new query with new parameters.
I searched on the Internet and in the Kendo UI's docs but didn't find how to make it.
Can someone explain to me what I am doing wrong?
Upvotes: 0
Views: 1387
Reputation: 20203
This is because by default filtering is performed client side. You need to enable server-side filter with the serverFiltering option set to true.
Upvotes: 1