I have a grid
@( Html.Kendo() .Grid<Papr2WebMvc4.Models.PiprForms.PartnershipForm>() .Name("partnerShipFormGrid") .Columns(columns => { columns.Bound(form => form.Id).Hidden(true);//0 columns.Bound(form => form.Date).Format("{0:M/yyyy}").Title("Month");//1 columns.Bound(form => form.CommentsDescriptionsNotes).Hidden(true).Title("Partnership Description");//8 columns.Command(command => { command.Edit(); command.Destroy(); }).Hidden(false); })//end columns .Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("AddEditPartnership").Window(window => window.Width(750))) .ToolBar(toolbar => toolbar.Create()) .Selectable(select => select.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row)) .DataSource(datasource => datasource .Ajax() .ServerOperation(true) .Model(model => model.Id(form => form.Id)) .Read(read => read.Action("GetForm", "Form", new { planId = Model.PlanId, planActivityId = Model.Activity.PlanActivityId, activityType = Model.Activity.ActivityType, activityTypeId = Model.Activity.ActivityTypeId }))//end read .Create(create => create.Action("AddForm", "Form", new { planActivityId = Model.Activity.PlanActivityId, activityTypeId = Model.Activity.ActivityTypeId }))//end create .Destroy(destroy => destroy.Action("DeleteForm", "Form", new { planActivityId = Model.Activity.PlanActivityId })) .Update(update => update.Action("EditForm", "Form", new { planActivityId = Model.Activity.PlanActivityId, activityTypeId = Model.Activity.ActivityTypeId })))//end datasource //.Events(events => events.Change("onChange").DataBound("onDataBound")) .Pageable(pages => pages.PageSizes(true)) )//end partnershipgrid
Here is my editor template
@model Papr2WebMvc4.Models.PiprForms.PartnershipForm
@{
if (!Model.Year.HasValue)
{
Model.Year = null;
}
if (!Model.Month.HasValue)
{
Model.Month = null;
}
Model.Groups= Model.GetGroups(Model.PlanActivityId, 0, Model.Id);
}
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>@Model.FormActivityType</legend>
<div class="editor-label">
Month partnerhsips were formed
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Month)/@Html.EditorFor(model => model.Year, new { @placeholder = "yyyy" })
</div>
@* @Html.Hidden("Date", new DateTime(Model.Year.Value, Model.Month.Value, 1))*@
<div>
@for(int i=0;i<Model.Groups.Count;i++)
{
<label>@Model.Groups.ElementAt(i).GroupName@Html.CheckBox("IsSelectedGroup"+@Model.Groups.ElementAt(i).GroupId)</label>
@*<label>@Model.Groups.ElementAt(i).GroupName@Html.CheckBoxFor(model => model.Groups.ElementAt(i).IsSelectedGroup, new { @id = "Group" + Model.Groups.ElementAt(i).GroupId })</label>*@
}
@* @{Html.RenderAction("GetGroups", "Form", new { planActivityId = Model.PlanActivityId,formId=Model.Id });}*@
</div>
<div class="editor-label">
@Html.LabelFor(model => model.CommentsDescriptionsNotes, "Additional description of new partnerships")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CommentsDescriptionsNotes)
</div>
</fieldset>
My problem is that I cannot get the checkbox to show selected when I select a form to edit. I also cannot seem to use checkboxfor in my edit templates because it says value is required and when I select one it selects them all. I can get my checkbox information to save properly using the regular checkbox method but this isn't working for getting those values back.I can use checkboxfor just fin outside of the grid editor templates.