This is a migrated thread and some comments may be shown as answers.

[Solved] Dropdown list not displaying first value after ajax refresh

0 Answers 106 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roland
Top achievements
Rank 1
Roland asked on 13 May 2011, 08:04 PM
I Hello all. I am implementing two dropdown lists where "Fund" dropdown list is populated by the selection of "Close Date" dropdown list (cascading). The problem is that after the Ajax update the "Fund" dropdown list displays a blank value instead of the first selection. I verified that the returned selections have the first item marked as "selected". I have also tried a couple things to default the selected index of the dropdown after update. So how do I get the dropdown to default to a particular selection afetr it's been updated. Lised below are code fragments for the definition of the dropdown lists and the javascript function that runs when "Close Date" is selected.

Using Telerik 2011.1.315

<script type="text/javascript">
 fundListUrl = '<%= Url.Action("GetFundList","Admin") %>'
 function GetFundList(e)
 {
  var fundDropDown = $('#FundId');
  var fundDropDownData = fundDropDown.data('tDropDownList');
  fundDropDownData.loader.showBusy();
  $.get(fundListUrl, { dateId: e.value }, function (data) {
   fundDropDownData.dataBind(data);
   fundDropDownData.loader.hideBusy();
   fundDropDown.attr('selectedIndex', 1);
  });
 }
</script>
...
<table>
 <tr>
  <td class="editlabel">Close Date:</td>
  <td>
   <%= Html.Telerik().DropDownListFor(o => o.ReportingPeriodDateId)
    .BindTo((SelectList)ViewData["closeDateList"])
    .ClientEvents(events => events.OnChange("GetFundList"))
    %>
  </td>
 </tr>
 <tr>
  <td class="editlabel">Fund:</td>
  <td>
   <%= Html.Telerik().DropDownListFor(o=>o.FundId)
    .BindTo((SelectList)ViewData["fundList"])
    .HtmlAttributes(new { style = "width: 40em;" })
   %>
  </td>
 </tr>
</table>


Tags
ComboBox
Asked by
Roland
Top achievements
Rank 1
Share this question
or