I have a combox where the choices are driven by a remote datasource as follows:
The comboxbox is also bound to a view model
My problem is that when the page initially loads, the combobox shows the value of the id field and not the label that corresponds to that id. This is not an issue if I use a local array as the datasource, but the remote datasource is filtered based on user input and not designed to look up label based on id.
In code (in the viewmodel actually) I have the value of the label corresponding to this id, and I would like it to appear when the form is loaded.
I was thinking to possibly append an additional item (current id/label) onto the datasource list of choices, but I also don't want to query the remote datasource unless the user interacts with the control.
What is a good way to have the combobox display the label when the page loads, but also not disturb the id value which is stored in the view model unless the user actually changes the control value?
Also, can anyone comment the use of input.val() to feed my remote query. I do want to use the value that the user has typed in, but am wondering if combobox has some built-in alternative to using input.val().
input.kendoComboBox({
dataTextField:
'label'
,
dataValueField:
'id'
,
dataSource: {
type:
"json"
,
serverFiltering:
true
,
transport: {
read: {
url: 'api/getchoices,
data: {
filter:
function
(){
return
input.val();
}
}
}
}
}
});
The comboxbox is also bound to a view model
<
input
data-role
=
"combobox"
data-bind
=
"value: id"
/>
In code (in the viewmodel actually) I have the value of the label corresponding to this id, and I would like it to appear when the form is loaded.
I was thinking to possibly append an additional item (current id/label) onto the datasource list of choices, but I also don't want to query the remote datasource unless the user interacts with the control.
What is a good way to have the combobox display the label when the page loads, but also not disturb the id value which is stored in the view model unless the user actually changes the control value?
Also, can anyone comment the use of input.val() to feed my remote query. I do want to use the value that the user has typed in, but am wondering if combobox has some built-in alternative to using input.val().