or
01.public ActionResult UpdateUnitListItemViewModel([DataSourceRequest] DataSourceRequest request, UnitListItemViewModel unitListItemViewModel)02. {03. if (ModelState.IsValid)04. {05. // Map a unit and save it06. Unit unit = UnitRepository.GetUnit(unitListItemViewModel.UnitID);07. 08. unit.Property.StatusID = unitListItemViewModel.PropertyStatusID;09. unit.Property.SubStatusID = unitListItemViewModel.PropertySubStatusID;10. 11. unit.StatusID = unitListItemViewModel.UnitStatusID;12. unit.SubStatusID = unitListItemViewModel.UnitSubStatusID;13. 14. 15. PropertyRepository.Update(unit.Property, LoggedInUser.UserID);16. UnitRepository.Update(unit, LoggedInUser.UserID);17. 18. }19. return Json(new[] { unitListItemViewModel }.ToDataSourceResult(request, ModelState));20. 21. }01.@(Html.Kendo().Grid<ARPS.OpsPortal.Models.UnitListItemViewModel>() 02. .Name("Grid")03. .DataSource(datasource => datasource04. .Ajax()05. .Group( group => group.Add(c => c.MarketName))06. .Sort( sort => sort.Add("FormattedAddress").Ascending())07. .Read(read => read.Action("GetUnitListItemViewModels", "Property"))08. .Update(update => update.Action("UpdateUnitListItemViewModel","Property"))09. .Model(model => model.Field(p => p.FormattedAddress).Editable(false))10. .Model(model => model.Field(p => p.Name).Editable(false))11. .Model(model => model.Id(u => u.UnitID))12. )13. .Columns(columns =>14. {15. columns.Bound(u => u.FormattedAddress).Title("Address");16. columns.Bound(u => u.Name).Title("Unit");17. columns.Bound(u => u.PropertyStatusName).Title("Property Status");18. columns.Bound(u => u.PropertySubStatusName).Title("Property Sub Status");19. columns.Bound(u => u.UnitStatusName).Title("Unit Status");20. columns.Bound(u => u.UnitSubStatusName).Title("Unit Sub Status");21. columns.Bound(u => u.AssignedUserInitials).Title("User");22. columns.Command(command => command.Edit());23. })24. .Editable(editable => editable.Mode(GridEditMode.InLine))25. .Pageable() 26. .Sortable()27.)01.@(Html.Kendo().DropDownList()02. .Name("PropertySubStatusID")03. .HtmlAttributes(new { style = "width:150px" })04. 05. .DataTextField("Name")06. .DataValueField("StatusID")07. .DataSource(source => {08. source.Read(read =>09. {10. read.Action("GetActiveSubStatuses", "Status")11. .Data("filterPropertySubStatuses");12. })13. .ServerFiltering(true);14. })15. .Enable(true)16. .SelectedIndex(0)17. .AutoBind(false)18. .CascadeFrom("PropertyStatusID")19. 20.)21. 22.<script type="text/javascript">23. 24. function filterPropertySubStatuses() {25. return {26. StatusID: $("#PropertyStatusID").val()27. };28. }29. 30.</script>I have the following code to bind a DropDownList for the Status property of a User Model. The Status is an enum.
The DropDownList for the first user (row 1 in the table) is rendered correctly - however subsequent rows the DropDownList is not rendered - it is rendered as an empty text box. If I use 'Vanilla Razor' DropDownList then the controls are rendered correctly - what is wrong?
Thanks
Ian
@model IEnumerable<CLOCS.Models.ApplicationUser>@{ ViewBag.Title = "Index";}<h2>Index</h2><p> @Html.ActionLink("Create New", "Create")</p><table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.UserName) </th> <th> </th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.UserName) </td> @*<td> @Html.EnumDropDownListFor(modelItem => item.Status) </td>*@ <td> @Html.Kendo().DropDownListFor(modelItem => item.Status).BindTo(EnumHelper.GetSelectList(item.Status.GetType())) </td> <td> @Html.ActionLink("Edit", "Edit", new { id = item.Id }) | @Html.ActionLink("Details", "Details", new { id = item.Id }) | @Html.ActionLink("Delete", "Delete", new { id = item.Id }) </td> </tr> }</table>@model PASSAdmin.ViewModels.ResourceReviewer.ResourceReviewViewModel@{ bool disabled = true; if (Model.Status == "BLREV") { disabled = false; }}@Html.HiddenFor(model => model.Beamline_Request_ID, Model.Beamline_Request_ID)@Html.HiddenFor(model => model.Status, Model.Status)<div class="editor-container" style="width:700px;"> <p>Please provide your recommendation of the experiment described in this Beam Time Request with regard to feasibility and safety.</p> <div> <div class="editor-label"> @Html.Label("Approve") </div> <div class="editor-field"> @if (disabled) { @Html.RadioButtonFor(model => model.Refused_By_Beamline, "N", new { disabled = true }) } else { @Html.RadioButtonFor(model => model.Refused_By_Beamline, "N") } </div> <div class="editor-label"> @Html.Label("Deny") </div> <div class="editor-field"> @if (disabled) { @Html.RadioButtonFor(model => model.Refused_By_Beamline, "Y", new { disabled = true }) } else { @Html.RadioButtonFor(model => model.Refused_By_Beamline, "Y") } </div> </div> <br class="clear" /> <br /> <br /> <p>By selecting Approve you are signifying the Experiment is feasible and can be performed safely on the indicated Beamline. If you select to Deny any of the above, please provide an explanation in the Comments area below. In addition to any specific comments, it is suggested you make note of any particular beamline equipment to be used during this experiment. Other staff may not have access to the full proposal information, but will have access to these comments.</p> @* <div class="editor-label"> @Html.Label("Comments") </div> <div class="editor-field"> @Html.EditorFor(model => model.Refused_By_Beamline, "N") @Html.ValidationMessageFor(model => model.Refused_By_Beamline) </div> *@ <p>Note: comments entered here are visible to the Principal Investigator</p></div>@(Html.Kendo().Grid<ExpenseReport.MVC.Models.ExpenseReportModel>() .Name("Grid") .Columns(columns => { columns.Bound(p => p.ExpenseReportId).Visible(true); columns.Bound(p => p.ExpenseLineItemId).Visible(true); columns.Bound(p => p.ExpenseTypeDesc).Title("Expense Type"); columns.Bound(p => p.City).Title("City"); columns.Bound(p => p.StateName).Title("State"); columns.Bound(p => p.Date).Format("{0:d}").Title("Date"); columns.Bound(p => p.Amount).Title("Amount"); columns.Bound(p => p.EndingMileage).Title("Ending Mileage"); columns.Bound(p => p.BeginningMileage).Title("Beginning Mileage"); columns.Command(command => { command.Edit(); command.Destroy(); }); }) .ToolBar(toolbar => toolbar.Create().HtmlAttributes(new { id = "btnAdd" })) .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("NewExpense").Window(w => w.Width(500))) .Pageable() .Scrollable() .HtmlAttributes(new { style = "height:430px; width=100%" }) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Events(events => events.Error("error_handler")) .Model(model => { model.Id(p => p.ExpenseReportId); model.Id(p => p.ExpenseLineItemId); }) .Create(create => create .Action("EditingPopup_Create", "ExpenseReport") .Data("erLineItemsCreateData")) //.Read(read => read // .Action("EditingPopup_Read", "ExpenseReport") // .Data("erLineItemsReadData")) .Update(update => update .Action("EditingPopup_Update", "ExpenseReport").Type(HttpVerbs.Post) .Data("erLineItemsUpdateData")) .Destroy(update => update .Action("EditingPopup_Destroy", "ExpenseReport").Type(HttpVerbs.Post))) ) <script> function error_handler(e) { if (e.errors) { var message = "Errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += this + "\n"; }); } }); alert(message); } } //pass additional data to the READ action method function erLineItemsReadData() { return { expenseReportId: "@ViewBag.ExpenseReportId" }; } function erLineItemsCreateData() { return { expenseReportId: "@ViewBag.ExpenseReportId" }; } function erLineItemsUpdateData() { return { expenseReportId: "@ViewBag.ExpenseReportId", expenseLineItemId: "@ViewBag.ExpenseLineItemId" }; }[AcceptVerbs(HttpVerbs.Post)] public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ExpenseReportModel erLineItem, int expenseReportId, int expenseLineItemId) { if (erLineItem != null && ModelState.IsValid) { globalKip.UpdateExpenseReportLineItem(expenseReportId, erLineItem.ExpenseTypeDesc, erLineItem.Date, erLineItem.Amount, erLineItem.City, erLineItem.StateName, erLineItem.EndingMileage, erLineItem.BeginningMileage); } return Json(new[] { erLineItem }.ToDataSourceResult(request, ModelState)); }Message: Exception: System.InvalidCastException: Unable to cast object of type 'Kendo.Mvc.CompositeFilterDescriptor' to type 'Kendo.Mvc.FilterDescriptor'. at Kendo.Mvc.Infrastructure.Implementation.FilterNodeVisitor.Visit(PropertyNode propertyNode) at Kendo.Mvc.Infrastructure.Implementation.OrNode.Accept(IFilterNodeVisitor visitor) at Kendo.Mvc.UI.DataSourceRequestModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)