Hello Matt,
I would suggest you to carefully review the following Virtualization demo of the MVC DropDownList:
https://demos.telerik.com/aspnet-mvc/dropdownlist/virtualization
The ValueMapper function is defined like so:
function valueMapper(options) {
$.ajax({
url: "@Url.Action("Orders_ValueMapper", "DropDownList")",
data: convertValues(options.value),
success: function (data) {
options.success(data);
}
});
}
In calls a remote endpoint which iterates all items that should be present in the DropDownList source:
public ActionResult Orders_ValueMapper(int[] values)
{
var indices = new List<int>();
if (values != null && values.Any())
{
var index = 0;
foreach (var order in GetOrders())
{
if (values.Contains(order.OrderID))
{
indices.Add(index);
}
index += 1;
}
}
return Json(indices, JsonRequestBehavior.AllowGet);
}
It also uses a helper function to convert the values to indices:
function convertValues(value) {
var data = {};
value = $.isArray(value) ? value : [value];
for (var idx = 0; idx < value.length; idx++) {
data["values[" + idx + "]"] = value[idx];
}
return data;
}
All the above is needed so that the virtualization of the DropDownList works properly when its initial value is sent.
If you you face any issues with the above, I would like to ask you to prepare and send me a small isolated runnable sample reproducing the problem. Please, remove any external dependencies and database calls and use sample data created on the server. This way I will be able to troubleshoot the case locally.
As per the initial value of the DropDownList observed, in order to properly populate the widget, a mapper (and a remote) call is needed. Therefore, the change observed is expected.
Regards,
Veselin Tsvetanov
Progress Telerik