} .cs -------------------------------- using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Syncfusion.EJ2.Base; namespace NclHome.Pages.Applications.ControlPanel.HrDataManagement; public class TestModel : PageModel { public List HrDataViewModel { get; set; } = new List (); public TestModel() { } public void OnGet() { HrDataViewModel.Add(new HrDataViewModel { EmpId = 3, FullName = \"Mr. Santosh Pradhan\", DateOfSuperannuation = DateTime.Now.AddDays(-2), IsWorking = true }); HrDataViewModel.Add(new HrDataViewModel { EmpId = 4, FullName = \"Mr. Sekhar Pradhan\", DateOfSuperannuation = DateTime.Now.AddDays(-3), IsWorking = false }); HrDataViewModel.Add(new HrDataViewModel { EmpId = 5, FullName = \"Mr. Deepak Pradhan\", DateOfSuperannuation = DateTime.Now.AddDays(1), IsWorking = false }); } public async Task OnPostUpdateAsync([FromBody] CRUDModel crudModel) { //update logic Here return new JsonResult(crudModel.Value); } } public class HrDataViewModel { public int EmpId { get; set; } public string FullName { get; set; } public DateTime? DateOfSuperannuation { get; set; } public bool? IsWorking { get; set; } } ", "answerCount": 1, "datePublished": "2023-12-11T10:12+00:00", "author": { "@type": "Person", "name": "Mithun Pradhan", "url": "https://www.c-sharpcorner.com/members/mithun-pradhan3" } , "suggestedAnswer": [ { "@type": "Answer", "text": " Problem The code has a bug that prevents the inline editing functionality from working correctly for the DateOfSuperannuation and IsWorking columns. When attempting to edit these columns inline, the changes are not saved. Cause The cause of the bug is that the DateOfSuperannuation and IsWorking properties in the HrDataViewModel class are not marked as editable. This prevents the grid from recognizing these columns as editable and saving the changes. Solution To fix the bug and enable inline editing for the DateOfSuperannuation and IsWorking columns, you need to update the HrDataViewModel class and the grid configuration in the Razor page. In the HrDataViewModel class, add the [Editable(true)] attribute to the DateOfSuperannuation and IsWorking properties. This attribute marks the properties as editable. public class HrDataViewModel { public int EmpId { get; set; } public string FullName { get; set; } [Editable(true)] public DateTime? DateOfSuperannuation { get; set; } [Editable(true)] public bool? IsWorking { get; set; } } In the Razor page, update the e-grid-columns section to include the edit property for the DateOfSuperannuation and IsWorking columns. Set the edit property to true to enable inline editing for these columns. With these changes, the DateOfSuperannuation and IsWorking columns will be editable, and any changes made inline will be saved. ", "upvoteCount": 2, "url": "https://www.c-sharpcorner.com/forums/inline-edit-not-working-column-dateofsuperannuation-and-isworking", "datePublished": "2023-12-15T06:01+00:00", "author": { "@type": "Person", "name": "Jayraj Chhaya", "url": "https://www.c-sharpcorner.com/members/jayraj-chhaya" } } ] } }
1
Answer

Inline edit not working column DateOfSuperannuation and IsWorking

My code
-----------

@page
@model NclHome.Pages.Applications.ControlPanel.HrDataManagement.TestModel

@Html.AntiForgeryToken()

@{
    ViewData["Title"] = "HR Data Management";
}

<div>
    <ejs-grid id="Grid" allowPaging="true" 
              load="onLoad" toolbar="@(new List<string> { "Edit","Cancel", "Update" })">
        <e-grid-editSettings allowAdding="false" allowDeleting="false" allowEditing="true" allowEditOnDblClick="true" showDeleteConfirmDialog="true"></e-grid-editSettings>
        <e-data-manager json="@Model.HrDataViewModel.ToArray()" adaptor="RemoteSaveAdaptor"
                        updateUrl="Test?handler=Update"></e-data-manager>
        <e-grid-pageSettings pageSize="10" pageSizes="@(new[] {"10","50", "100", "All"})" />
        <e-grid-columns>
            <e-grid-column field="EmpId" headerText="EmpId" width="15" allowEditing="false"></e-grid-column>
            <e-grid-column field="FullName" headerText="Full Name" width="40" allowEditing="false"></e-grid-column>
            <e-grid-column field="DateOfSuperannuation" headerText="Date Of Superannuation" type="date" format="dd-MM-yyyy" editType="datepickeredit" width="30"></e-grid-column>
            <e-grid-column field="IsWorking" headerText="IsWorking" displayAsCheckBox="true" type="boolean" editType="booleanedit" width="15"></e-grid-column>
        </e-grid-columns>
    </ejs-grid>
</div>

@section Scripts {
    <script type="text/javascript">

        function onLoad() {
            this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
        }

    &lt;/script&gt;
}

.cs
--------------------------------

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Syncfusion.EJ2.Base;

namespace NclHome.Pages.Applications.ControlPanel.HrDataManagement;

public class TestModel : PageModel
{

    public List<HrDataViewModel> HrDataViewModel { get; set; } = new List<HrDataViewModel>();
    public TestModel()
    {
        
    }
    public void OnGet()
    {
        HrDataViewModel.Add(new HrDataViewModel
        {
            EmpId = 3,
            FullName = "Mr. Santosh Pradhan",
            DateOfSuperannuation = DateTime.Now.AddDays(-2),
            IsWorking = true
        });
        HrDataViewModel.Add(new HrDataViewModel
        {
            EmpId = 4,
            FullName = "Mr. Sekhar Pradhan",
            DateOfSuperannuation = DateTime.Now.AddDays(-3),
            IsWorking = false
        });
        HrDataViewModel.Add(new HrDataViewModel
        {
            EmpId = 5,
            FullName = "Mr. Deepak Pradhan",
            DateOfSuperannuation = DateTime.Now.AddDays(1),
            IsWorking = false
        });
    }

    public async Task<JsonResult> OnPostUpdateAsync([FromBody] CRUDModel<HrDataViewModel> crudModel)
    {
        
        //update logic Here

        return new JsonResult(crudModel.Value);
    }

}
public class HrDataViewModel
{
    public int EmpId { get; set; }
    public string FullName { get; set; }
    public DateTime? DateOfSuperannuation { get; set; }
    public bool? IsWorking { get; set; }
}

Answers (1)