My checkbox values for 'Administrator' and 'GroupAdmin' are not being posted up the controller?
Any idea what I'm doing wrong?
I have a grid defined as
@(Html.EJ().Grid<object>("UserListing")
.Datasource(ds => ds.URL("Users/DataSource").UpdateURL("Users/Update").InsertURL("Users/Insert").RemoveURL("Users/Delete").Adaptor(AdaptorType.UrlAdaptor))
.AllowGrouping()
.GroupSettings(group => { group.EnableDropAreaAutoSizing(false); })
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.EditSettings(edit =>
{
edit.AllowAdding()
.AllowDeleting()
.AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#CreateUserDiv");
})
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("UserID").HeaderText("ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(50).AllowGrouping(false).Add();
col.Field("Username").HeaderText("User Name").Width(50).AllowGrouping(false).EditType(EditingType.String).Add();
col.Field("DisplayName").HeaderText("Name").Width(100).AllowGrouping(false).EditType(EditingType.String).Add();
col.Field("JobTitle").HeaderText("Job Title").Width(100).EditType(EditingType.String).Add();
col.Field("Email").HeaderText("Email").Width(100).EditType(EditingType.String).Add();
col.Field("Department").HeaderText("Department").Width(100).Add();
col.Field("Administrator").Visible(false).EditType(EditingType.Boolean).Add();
col.Field("GroupAdmin").Visible(false).EditType(EditingType.Boolean).Add();
col.HeaderText("").Template("<a rel='nofollow' href='/Users/Users/Edit/{{:UserId}}'><i class='glyphicon glyphicon-pencil'></i></a>").AllowFiltering(false).Width(20).Add();
})
.ClientSideEvents(eve => eve.ActionBegin("begin"))
)
and a template for inserting and editing defined as
<script type="text/template" id="CreateUserDiv">
<b>New Staff</b>
<table cellspacing="10">
<tr>
<td style="text-align: right;">
Username
</td>
<td style="text-align: left">
<input id="Username" name="Username" value="{{: Username}}" class="e-field e-ejinputtext valid"
style="text-align: right; width: 150px; height: 28px" />
<br />
<a rel='nofollow' href="#" id="checkUser">check user</a>
</td>
</tr>
<tr>
<td style="text-align: right;">
Email
</td>
<td style="text-align: left">
<input id="Email" name="Email" value="{{: Email}}" class=" e- e-field e-ejinputtext valid"
style="text-align: right; width: 200px; height: 28px" />
</td>
<td style="text-align: right;">
Name
</td>
<td style="text-align: left">
<input id="DisplayName" name="DisplayName" value="{{: DisplayName}}" class="e-field e-ejinputtext valid"
style="width: 150px; height: 28px" />
</td>
</tr>
<tr>
<td style="text-align: right;">
Job Title
</td>
<td style="text-align: left">
<input type="text" id="JobTitle" name="JobTitle" value="{{:JobTitle}}" style="text-align: right;" />
</td>
<td style="text-align: right;">
Roles
</td>
<td style="text-align: left">
{{if Administrator}}
<input type="checkbox" id="Administrator" name="Administrator" checked="checked" class="e-field e-checkbox valid" style="width:30px" />
{{else}}
<input type="checkbox" id="Administrator" name="Administrator" class="e-field e-checkbox valid" style="width:30px" />
{{/if}}
{{if GroupAdmin}}
<input type="checkbox" id="GroupAdmin" name="GroupAdmin" checked="checked" class="e-field e-checkbox valid" style="width:30px" />
{{else}}
<input type="checkbox" id="GroupAdmin" name="GroupAdmin" class="e-field e-checkbox valid" style="width:30px" />
{{/if}}
</td>
</tr>
</table>
</script>
which posts to controller method
[HttpPost]
public ActionResult Update([Bind(Include = "RolesSubmitted")]UserPartial value, FormCollection form)
{
return null;
}