So I have a page where I'm using a combobox to allow users to filter some data by Contact.
I now have a requirement to pre-filter this data from a value passed by a querystring parameter.
I am initially thinking about automating the combobox using the client-side api and have found the commands I need.
I've chucked a temporary button onto my page to test out the script (I will probably execute this from the document ready function in the final app)
If I execute these steps individually from the console I get the required effect. The text is entered, the search runs, the contact is selected and the combobox closes.
However, because the data is remote, the .select() and .close() execute before the .search() has completed.
Is there any way to chain these commands so that the .select() only fires after the .search() has completed?
The combobox is currently declared thus:
Cheers,
Nick
I now have a requirement to pre-filter this data from a value passed by a querystring parameter.
I am initially thinking about automating the combobox using the client-side api and have found the commands I need.
I've chucked a temporary button onto my page to test out the script (I will probably execute this from the document ready function in the final app)
$(
"#btnTest"
).click(
function
() {
try
{
$(
"#contactFilter"
).data(
"kendoComboBox"
).text(
"MySurname"
);
$(
"#contactFilter"
).data(
"kendoComboBox"
).search();
$(
"#contactFilter"
).data(
"kendoComboBox"
).select(
function
(dataItem) {
return
dataItem.Id ===
"myUserId"
});
$(
"#contactFilter"
).data(
"kendoComboBox"
).close();
}
catch
(e) {
if
(console) console.log(e.message);
}
});
If I execute these steps individually from the console I get the required effect. The text is entered, the search runs, the contact is selected and the combobox closes.
However, because the data is remote, the .select() and .close() execute before the .search() has completed.
Is there any way to chain these commands so that the .select() only fires after the .search() has completed?
The combobox is currently declared thus:
$(
"#contactFilter"
).kendoComboBox({
placeholder:
"contact name"
,
dataTextField:
"Name"
,
dataValueField:
"Id"
,
template: kendo.template($(
"#ContactFilterItemTemplate"
).html()),
filter:
"contains"
,
autoBind:
false
,
minLength: 3,
delay: 500,
dataSource: {
type:
"json"
,
serverFiltering:
true
,
transport: {
read: {
url: Cmdb.SiteRoot +
"Groupings/ContactsTypeahead"
,
global:
false
,
data:
function
() {
return
{
filterString: $(
"#contactFilter"
).data(
"kendoComboBox"
).input.val()
};
}
}
}
}
});
Cheers,
Nick