This question is locked. New answers and comments are not allowed.
Hello.
I have a problem with dropdownlist templates in ajaxbound mode...
I use [UIHInt("myTemplate")] at the property like this:
| public class myViewModel |
| { |
| public string Name { get; set; } |
| [UIHint("AddressComboTemplate")] |
| public Address theAddress { get; set; } |
| } |
Then I setup my grid:
| <%= Html.Telerik().Grid<myViewModel>() |
| .Name("myGrid") |
| .Pageable(page => page.PageSize(15) |
| .Position(GridPagerPosition.Both)) |
| .DataBinding(databinding => databinding.Ajax() |
| .Select("_Index","MotivoMovimientoSituacion")) |
| .Columns(columns => |
| { |
| columns.Bound(o => o.Name); |
| columns.Bound(o => o.theAddress).ClientTemplate("<#=theAdress.Description#>"); |
| }) |
| %> |
The Edit Template for my "Address" field (AddressComboTemplate.ascx) is:
| <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Address>" %> |
| <%= Html.DropDownListFor(o => o.Id, new SelectList(new AddressProxy().GetAll(),"Id","Description", (Model != null) : Model.Id ? String.Empty))%> |
At runtime, when you edit (ajax) a row, the template gets rendered, but the selected value of the combo is always the first of the list, instead the row's current value... I've found a workaround for this, tapping the 'click' event of the Edit button and setting the value of the dropdownlist to the right one, but it makes me adding extra javascript and a "OnClientDataRow" event for the grid on every grid with one or more dropdownlist combos.
Is this a bug, or am I doing anything wrong?
Thanks!