Hi,
I just spent the last couple of hours trying to get the ComboBox to work, but no luck so far. Here's the code breakdown:
Datasource:
ComboBox:
Problem:
The initial dataset that the datasource returns does not contain value 99 (Some Event).
When I set autoBind to false then the value and text are correctly shown upon initialization.
BUT, when I simply click the little arrow on the dropdown, the data is bound, the text "Some Event" disappears, and the shown text is set to 99 (aka the value).
Even when I don't actually select another item from the combobox, it keeps showing 99.
I've tried using the datasource filter to filter the selected event id, but I cannot unset this filter afterwards (or don't know how to do this properly; everything I tried just made things worse).
Can anyone tell me what I'm doing wrong here? Also, if someone has a clean and working solution to this, I recommend adding it to the documentation because more people seem to be struggling with this (based on similar threads in this forum).
Regards,
Rinck
I just spent the last couple of hours trying to get the ComboBox to work, but no luck so far. Here's the code breakdown:
Datasource:
var
event_datasource =
new
kendo.data.DataSource({
transport: {
read: {
url:
"/event/datawidget"
,
dataType:
"json"
,
type:
"POST"
},
parameterMap:
function
(data) {
return
kendo.stringify(data);
}
},
schema: {
data:
"data"
,
total:
"total"
,
model: {
id:
"event_id"
,
fields: {
event_id: { type:
"number"
},
description: { type:
"string"
}
}
}
},
sort: { field:
"description"
, dir:
"desc"
}
pageSize: 10,
serverFiltering:
true
,
serverPaging:
true
});
var
event_widget = $(
"#event_id"
).kendoComboBox({
dataTextField:
"description"
,
dataValueField:
"event_id"
,
filter:
"contains"
,
minLength: 2,
dataSource: event_datasource,
placeholder:
"Select an event"
,
value:
'99'
,
text:
'Some event'
,
change :
function
(e) {
if
(
this
.value() &&
this
.selectedIndex == -1)
this
.value(
null
);
// clears the selection when an invalid selection was made
},
autoBind: false
}).data(
'kendoComboBox'
);
The initial dataset that the datasource returns does not contain value 99 (Some Event).
When I set autoBind to false then the value and text are correctly shown upon initialization.
BUT, when I simply click the little arrow on the dropdown, the data is bound, the text "Some Event" disappears, and the shown text is set to 99 (aka the value).
Even when I don't actually select another item from the combobox, it keeps showing 99.
I've tried using the datasource filter to filter the selected event id, but I cannot unset this filter afterwards (or don't know how to do this properly; everything I tried just made things worse).
Can anyone tell me what I'm doing wrong here? Also, if someone has a clean and working solution to this, I recommend adding it to the documentation because more people seem to be struggling with this (based on similar threads in this forum).
Regards,
Rinck