This question is locked. New answers and comments are not allowed.
Found a bug with the DatePicker although I'm guessing that the same bug applies to most of the controls.
I have a model as follows:
| public class Order |
| { |
| public List<ShippingLocations> Locations { get; set; } |
| { |
| public class ShippingLocation |
| { |
| public DateTime? EventDate { get; set; } |
| } |
I'm using MvC 2.0's support for binding to collections as follows:
| <table> |
| <% for (int i=0; i < Model.ShippingLocations.Count; i++) { %> |
| <tr> |
| <td> |
| <%=Html.EditorFor(x => x.ShippingLocations[i].EventDate)%> |
| </td> |
| <tr> |
| <% }%> |
| </table> |
And of course I use a Date.ascx template for instantiating the Telerik DatePicker control which I have not included here for brevity.
The control renders find (with the little calendar on the right) and the markup looks fine, but the control doesn't work when you click on it.
This is because the Telerik controls do not generate correct identifiers when binding to collections. Notice below that the id attribute of the outer DIV has bracket characters (which are invalid in html id attributes). Whenever MvC detects you are binding to a collection, brackets are converted to underscores. I've also included what MvC would have generated as a sample.
| // incorrect identifier as generated by Telerik |
| // html does not allow brackets in identifiers |
| <DIV id="ShippingLocations[0]_ShipByDate" class="t-widget t-datepicker"> |
| <INPUT ... /><A...>select date</A></DIV> |
| // correct identifier as though generated by MvC (assuming the MvC naming conventions) |
| <DIV id="ShippingLocations_0__ShipByDate" class="t-widget t-datepicker"> |
| <INPUT ... /><A...>select date</A></DIV> |
Because the identifiers are invalid, the generated jQuery selectors do not bind to the elements since they cannot be found.
So I have to ask, I've got a project due in literally less than a week. What's the chance of a super-quick hotfix?