Dropdown not selecting item when populating with Javascript

1 posts, 0 answers
  1. amarbir
    amarbir avatar
    7 posts
    Member since:
    Apr 2016

    Posted 26 Feb 2018 Link to this post

    Hi,

    I have done everything i.e. the client side api in documentation shows, but dropdown list will not show the selected item. The item is selected when drop down list is expanded (i.e. dropped down ). It shows the item as yellow (highlighted). But after list is loaded it does not show the item in text element. This leads to false required field validator alarm in browser. User have to reselect item. I am getting lot of complaints regarding this and I have failed to find a solution. I tried to do force selection by but than required field validator still fails.

    Here is the code:

    var ddlRef = $find(controlIds.refNumDdlId);
    ddlRef.trackChanges();
    ddlRef.get_items().clear();
    for (var i = 0; i < data.length; i++) {
        var comboItem = new Telerik.Web.UI.DropDownListItem();
        comboItem.set_text(data[i]);
        comboItem.set_value(data[i]);
        if (pceObject.ReferenceNumber && pceObject.ReferenceNumber == data[i]) {
            comboItem.select();
            scopeData.selectedRefNum = data[i];
        }
        ddlRef.get_items().add(comboItem);
    }
    if (scopeData.selectedRefNum) {
        var el = ddlRef.get_textElement();
        $(el).text(scopeData.selectedRefNum);
    }
    ddlRef.saveClientState();
    ddlRef.commitChanges();

     

Back to Top