Hi Team,
Getting ajax call twice for same input if specifying minLength in multiselect. Could you please suggest why ajax call invoke twice for same input with minLength.
HTML:<div><select id="required" multiple="multiple" style="width: 92.5%; margin-top: 21px; margin-left: 2px;" "></select></div>
JS Code:
var searchuserdataSource = new kendo.data.DataSource({
pageSize: 30,
serverFiltering: true,
transport: {
read: function (options) {
var srctxt = {
//searchText: $('#required').data("kendoMultiSelect").input.val()
searchText:"Test"
};
var params = "{searchText: '" + srctxt.searchText + "'}";
$.ajax({
type:"POST",
url: "./Relationships.aspx/GetUserSearch",
data: params,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (result) {
var userslist = [];
if (typeof result.d !== 'undefined' && result.d.Completed)
{
$.each(result.d.Data, function (i, item) {
var map = {};
map["id"] = item.Id;
map["name"] = item.DisplayName;
userslist.push(map);
});
}
options.success(userslist);
},
error: function (result) {
options.error(result);
}
});
}
}
});
$("#required").kendoMultiSelect({
autoBind: false,
minLength: 3,
enforceMinLength: true,
dataSource: searchuserdataSource,
dataTextField: "name",
dataValueField: "id",
//itemTemplate :"<input type='checkbox' id='#:data.id#'/> #:data.name#",
//itemTemplate: " <input type='checkbox' name ='#:data.name #' value ='#:data.id#' class='k-checkbox' /><label class='k-checkbox-label' value='#:data.id#' > #:data.name# </label>",
//itemTemplate:"<input type='checkbox' name='#:data.name # value='#:data.id #' class='k-checkbox' />" +
//"<span class='k-checkbox-label' data-value='#:data.id #'>#:data.name #</span>";
autoClose:false,
tagMode:"single",
//tagTemplate:'<span>#: data.values.length # user(s) selected</span>',
filter: "contains",
//placeholder: "Search..",
delay: 200,
close: function(){
var selectedItems =$("#required").data("kendoMultiSelect").dataItems();
if(selectedItems.length !=0)
{
$.each(selectedItems,function(index,obj){
//alert("Name: "+obj.name+"\n"+"Id:"+obj.id+"\n");
CreateUsersFilter(obj.id,obj.name);
});
if (dummyfiltersource.length >= 14)
$(".selectedusersgrid").width("94%");
}
}
});