I have DropDownList with a remote data source and serverFiltering.
<
input
ref
=
"combo3"
data-role
=
"dropdownlist"
data-value-primitive
=
"true"
data-text-field
=
"name"
data-value-field
=
"id"
data-filter
=
"contains"
data-bind
=
"value: combo3Value, source: combo3Source"
/>
My data source is like this (ES6 code)
combo3Source = new kendo.data.DataSource({
serverFiltering: true,
transport : {
read : (e)=>{
let url = "";
if ( e.data.filter && e.data.filter.filters.length === 1){
url = `/CI/search?text=${e.data.filter.filters[0].value}`;
this.httpClient.get(url).then((response)=>{
e.success(response.content);
});
}
else {
e.success([]);
}
}
}
});
As you can see in the code, my idea is to only fetch data if a filter is provided and return and empty result if no filter is provided. This approach works well but there is one edge case: If I load my form and the bound MVVM property already has a value then the DropDownList doesn't not know what text to display for the selected value. I expected that it would call the datasouce with a filter like "where id = 1829" but does not.
How am I supposed to provide the initial value?
Thanks
Sylvain