This question is locked. New answers and comments are not allowed.
I have a combobox set for Load On Demand. The issue is that when a user wants to edit a record, of which this combobox is a part of, then I need to set an initial value from the Model. However, it is complex and needs code to figure out how to format the text and value for the item. Therefore, I set the OnLoad to a clientside function and the initial Item binds correctly. However, when I call the SET() method to have it already selected and visible, It does not. So then I thought maybe, it was because I needed to do this after the OnLoad method was complete and try setting it in the OnDataBound event. So I pointed the combobox OnDataBound event towards a new function that selected the item. The OnDatabound is not being raised even though the DATABIND() method is being called in the OnLoad Function.
HERE IS THE COMBOBOX-
@(Html.Telerik()
.ComboBox()
.HtmlAttributes(new { style = "width: 300px" })
.Name("cbLoc")
.AutoFill(true)
.ClientEvents(c => c.OnDataBound("SetIndexOnLoadOnDemand").OnLoad("SetInitialLoadOnDemand"))
.DataBinding(dataBinding => dataBinding.WebService().Select("~/Code/WCF/LoadOnDemand.svc/LoadLocations"))
.Filterable(filtering =>
{
filtering.FilterMode(AutoCompleteFilterMode.StartsWith);
})
.HighlightFirstMatch(true)
)
HERE IS THE CLIENTSIDE FUNCTIONS-
function SetInitialLoadOnDemand(e) {
var combobox = $(this).data('tComboBox');
var LocTitle = $('#LocTitle').val();
var LocID = $('#LocID').val();
var dataSource = [
{ Text: LocTitle, Value: LocID }
];
combobox.dataBind(dataSource);
}
function SetIndexOnLoadOnDemand(e) {
var combobox = $(this).data('tComboBox');
combobox.select(1);
}
HERE IS THE COMBOBOX-
@(Html.Telerik()
.ComboBox()
.HtmlAttributes(new { style = "width: 300px" })
.Name("cbLoc")
.AutoFill(true)
.ClientEvents(c => c.OnDataBound("SetIndexOnLoadOnDemand").OnLoad("SetInitialLoadOnDemand"))
.DataBinding(dataBinding => dataBinding.WebService().Select("~/Code/WCF/LoadOnDemand.svc/LoadLocations"))
.Filterable(filtering =>
{
filtering.FilterMode(AutoCompleteFilterMode.StartsWith);
})
.HighlightFirstMatch(true)
)
HERE IS THE CLIENTSIDE FUNCTIONS-
function SetInitialLoadOnDemand(e) {
var combobox = $(this).data('tComboBox');
var LocTitle = $('#LocTitle').val();
var LocID = $('#LocID').val();
var dataSource = [
{ Text: LocTitle, Value: LocID }
];
combobox.dataBind(dataSource);
}
function SetIndexOnLoadOnDemand(e) {
var combobox = $(this).data('tComboBox');
combobox.select(1);
}