We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Dialog template not sending checkbox values to controller

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;
        }




1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team April 28, 2017 11:49 AM UTC

Hi Paul, 
Thanks for contacting Syncfusion support. 
We went through your code example and we have tried to replicate the issue at our end. But we were unable to reproduce the reported issue and we have created a sample for your convenience which can be download from following link, 

In this sample, we have rendered the Grid with dialog editing template as well as rendered the checkbox column which is replicate your code example. Server side data is sends correctly and we attached the screenshot for Post and server side action method. Please refer to the following screenshots, 
Screenshot 1:”Developer window” 
 
Screenshot 1:”Server side action method” 
 
Code example
@(Html.EJ().Grid<object>("FlatGrid") 
            .Datasource(ds => ds.URL("Data").UpdateURL("/Grid/Update").InsertURL("/Grid/Insert").RemoveURL("/Grid/Delete").Adaptor(AdaptorType.UrlAdaptor)) 
           . . . 
 
                      .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"); }) 
              . . . 
                      .Columns(col => 
        { 
                . . . 
            col.Field("Verified").Visible(false).EditType(EditingType.Boolean).HeaderText("Verified").Width(90).Add(); 
        })) 
 
<script type="text/template" id="template"> 
    <b>Order Details</b> 
    <table cellspacing="10"> 
               . . .   
            <td style="text-align: right;"> 
                Verified 
            </td> 
            <td style="text-align: left"> 
              {{if Verified}} 
                <input type="checkbox" id="Verified" name="Verified" checked="checked" class="e-field e-checkbox valid" style="width:30px" /> 
                {{else}} 
                <input type="checkbox" id="Verified" name="Verified" class="e-field e-checkbox valid" style="width:30px" /> 
                {{/if}} 
                
            </td> 
        </tr> 
         
    </table> 
</script> 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Live Chat Icon For mobile
Up arrow icon