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

CheckBoxFor control does not change the field data of form

Hi Team,
I use Grid control with Dialog Template mode. My template look like this:

   


The IsDiKhoiDiaPhuong and IsDiKhoiDiaPhuong are both Nullable Bool type.

When i submit the form from dialog to server, the value of these CheckBoxFor are not change. It keep the "false" value instead.







5 Replies

SD Saranya Dhayalan Syncfusion Team September 2, 2019 09:25 AM UTC

Hi Huy Ly, 

Thank you for contacting Syncfusion support. 

We have checked your reported issue and we would like to let you know that our EJ2 CheckBox doesn’t support nullable bool type. It supports only the Boolean value and accepts either true or false value. For more details regarding this, please refer the below link. 


Could you please check the above link and get back to us with more information like controller side code (model value binding for checkbox), if you still getting the issue or need any further assistance on this. 

Regards, 
Saranya 
 



HL Huy Ly September 6, 2019 03:23 AM UTC

I changed the Nullable bool type to Non-Nullable bool type, but with no luck. The value of these property still remain "false" when i submit to server.
I am using Syncfusion.EJ2, Version=17.2500.0.46






Attachment: CheckboxFor_f3bb7ead.rar


VK Vinoth Kumar Sundara Moorthy Syncfusion Team September 6, 2019 11:18 AM UTC

Hi Huy, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your reported issue and we suggest you to specify the actionBegin event for grid component. You must specify the name attribute for the Checkbox component. Please find the below code snippet, 
 
_EditPartial.cshtml 
<div class="form-row"> 
        <div class="col-md-4 form-group"> 
            @Html.EJS().CheckBoxFor(model => model.IsGiaoDucTaiDiaPhuong).Label("Giáo dục tại địa phương").Name("IsGiaoDucTaiDiaPhuong").Render() 
        </div> 
        <div class="col-md-4 form-group"> 
            @Html.EJS().CheckBoxFor(model => model.IsDuaVaoCoSoGiaoDuc).Label("Đưa vào cơ sở giáo dục").Name("IsDuaVaoCoSoGiaoDuc").Render() 
        </div> 
        <div class="col-md-4 form-group"> 
            @Html.EJS().CheckBoxFor(model => model.IsDangBiTruyTo).Label("Đang bị truy tố").Name("IsDangBiTruyTo").Render() 
        </div> 
    </div> 
    <div class="form-row"> 
        <div class="col-md-4 form-group"> 
            @Html.EJS().CheckBoxFor(model => model.IsAnCoHieuLuc).Label("Án có hiệu lực").Name("IsAnCoHieuLuc").Render() 
        </div> 
        <div class="col-md-4 form-group"> 
            @Html.EJS().CheckBoxFor(model => model.IsXoaXuLyHanhChinh).Label("Xóa xử lý hành chính").Name("IsXoaXuLyHanhChinh").Render() 
        </div> 
    </div> 
 
Index.cshtml 
@Html.EJS().Grid("ViPhamTaiPhamGrid").GridLines(Syncfusion.EJ2.Grids.GridLine.Both).DataSource(dataManager => 
{ 
    dataManager.Json(ViewBag.listViPhamTaiPham) 
.InsertUrl(ViewBag.InsertUrl).UpdateUrl(ViewBag.UpdateUrl).RemoveUrl(ViewBag.DeleteUrl).Adaptor("RemoteSaveAdaptor"); 
}).Query("new ej.data.Query().addParams('NguoiChapHanhID', 1)").AllowMultiSorting().AllowSorting().AllowFiltering().ActionComplete("ViPhamTaiPhamActionComplete").Columns(col => 
{ 
    col.Field("ID").HeaderText("ID").IsIdentity(true).IsPrimaryKey(true).Visible(false).Add(); 
    col.Field("NoiDung").HeaderText("Nội dung").Add(); 
 
 
}).ActionBegin("begin").AllowPaging().PageSettings(page => { page.PageCount(3); page.PageSize(5); }).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).Template("#NguoiChapHanhChiTietDialogTemplate"); edit.ShowDeleteConfirmDialog(true); }).Toolbar(new List<string> 
    () { "Add", "Edit", "Delete", "Update", "Cancel", "Search" }).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).Locale("vi").Render() 
 
 
function begin(e) { 
        if (e.requestType == "save") { 
            e.data['IsGiaoDucTaiDiaPhuong'] = e.form.querySelector("#IsGiaoDucTaiDiaPhuong").ej2_instances[0].checked; 
            e.data['IsDuaVaoCoSoGiaoDuc'] = e.form.querySelector("#IsDuaVaoCoSoGiaoDuc").ej2_instances[0].checked; 
            e.data['IsDangBiTruyTo'] = e.form.querySelector("#IsDangBiTruyTo").ej2_instances[0].checked; 
            e.data['IsAnCoHieuLuc'] = e.form.querySelector("#IsAnCoHieuLuc").ej2_instances[0].checked; 
            e.data['IsXoaXuLyHanhChinh'] = e.form.querySelector("#IsXoaXuLyHanhChinh").ej2_instances[0].checked; 
        } 
    } 
 
For your convenience we have prepared a sample. Please find the sample in below link,  
 
Could you please check the above details and get back to us if you need any further assistance on this? 
 
Regards, 
Vinoth Kumar S 



HL Huy Ly September 7, 2019 01:45 PM UTC

It works as expected. Thank you so much for your support. Have a nice day Team!


AB Ashokkumar Balasubramanian Syncfusion Team September 9, 2019 07:29 AM UTC

Hi Huy,  
 
We are glad to hear that the problem has been resolved. Please let us know, if you need any further assistance. 
 
Regards, 
Ashokkumar B. 


Loader.
Live Chat Icon For mobile
Up arrow icon