ECie
ECie

Reputation: 1487

Kendo Grid Pop Up edit not firing Controller method on save

I have a kendo grid with enabled pop Up editing. It doesnt fire the controller method on update. Here is my code:

@(Html.Kendo().Grid<Trabaho.Model.Models.ProfileApplicationSubset>()
.Name("Assessment")
    .Columns(columns =>
    {
        columns.Bound(c => c.Position).Width(200).Groupable(true);
        columns.Bound(c => c.FirstName).Width(150).Groupable(false);
        columns.Bound(c => c.MiddleName).Width(150).Groupable(false);
        columns.Bound(c => c.LastName).Width(150).Groupable(false);
        columns.Bound(c => c.DesiredSalary).Width(150).Groupable(false);
        columns.Bound(c => c.Email).Width(150).Groupable(true);
        columns.Bound(c => c.Mobile).Width(150).Groupable(false);
        columns.Bound(p => p.Region).Width(300);
        columns.Bound(p => p.Province).Width(300);
        //columns.Bound(c => c.Region).Width(150);
        //columns.Bound(c => c.Province).Width(150);
        columns.Bound(c => c.City).Width(150);
        columns.Bound(c => c.Barangay).Width(150);
        columns.Bound(c => c.Gender).Width(150);
        columns.Bound(c => c.Recruiter).Width(150).Groupable(true);
        columns.Command(command => { command.Edit(); }).Width(160);
    })
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.ToolBar(tools => tools.Excel())
.Navigatable()
.Pageable(page => page
        .ButtonCount(5)
        .PageSizes(new[] { 50, 100, 500,1000 })
        .Refresh(true))
.Sortable()
.Scrollable()
.Groupable()
.Filterable()

.Reorderable(r => r.Columns(true))
.Resizable(r => r.Columns(true))
.ColumnMenu()
.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(500)
    .Read(read => read.Action("_GetForAssessment", "DashBoard"))
    .Events(events => events.Error("error_handler"))
    .Model(model => { model.Id(p=>p.ApplicationId); model.Field(p => p.ApplicationId); })
    .Update(update => update.Action("_Assessment", "DashBoard"))
    .Update(read => read.Type(HttpVerbs.Post))



)
)

<script type="text/javascript">
 function error_handler(e) {
    if (e.errors) {
        var message = "Errors:\n";
        $.each(e.errors, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function () {
                    message += this + "\n";
                });
            }
        });
        alert(message);
    }
}

And in the controller method i have these actions to update and read

        public ActionResult _GetForAssessment([DataSourceRequest] DataSourceRequest request)
    {
        var user = GetLinkedProfile(true);
        var jsons = _applicationService.GetApplicantsForAssesments("Metro Manila").ToList();
        return Json(jsons.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult _Assessment([DataSourceRequest] DataSourceRequest request, ProfileApplicationSubset model)
    {
        if (model == null || !ModelState.IsValid)
            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        var jobApp = _applicationService.Find(model.ApplicationId);
        jobApp.EmploymentStatus = model.ApplicationStatus;
        jobApp.ObjectState = ObjectState.Modified;
        _applicationService.Update(jobApp);
        _unitOfWork.SaveChanges();
        return Json(new[] { model }.ToDataSourceResult(request, ModelState));
    }

the Controller name is DashBoard, The console window shows no Error but the breakpoint in the the update method is not hit.. Can anyone tell me what is wrong with my configuration??

Upvotes: 0

Views: 1276

Answers (1)

Deepak
Deepak

Reputation: 119

use this one 
@(Html.Kendo().Grid<Trabaho.Model.Models.ProfileApplicationSubset>()
.Name("Assessment")
    .Columns(columns =>
    {
        columns.Bound(c => c.Position).Width(200).Groupable(true);
        columns.Bound(c => c.FirstName).Width(150).Groupable(false);
        columns.Bound(c => c.MiddleName).Width(150).Groupable(false);
        columns.Bound(c => c.LastName).Width(150).Groupable(false);
        columns.Bound(c => c.DesiredSalary).Width(150).Groupable(false);
        columns.Bound(c => c.Email).Width(150).Groupable(true);
        columns.Bound(c => c.Mobile).Width(150).Groupable(false);
        columns.Bound(p => p.Region).Width(300);
        columns.Bound(p => p.Province).Width(300);
        //columns.Bound(c => c.Region).Width(150);
        //columns.Bound(c => c.Province).Width(150);
        columns.Bound(c => c.City).Width(150);
        columns.Bound(c => c.Barangay).Width(150);
        columns.Bound(c => c.Gender).Width(150);
        columns.Bound(c => c.Recruiter).Width(150).Groupable(true);
        columns.Command(command => { command.Edit(); }).Width(160);
    })
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.ToolBar(tools => tools.Excel())
.Navigatable()
.Pageable(page => page
        .ButtonCount(5)
        .PageSizes(new[] { 50, 100, 500,1000 })
        .Refresh(true))
.Sortable()
.Scrollable()
.Groupable()
.Filterable()

.Reorderable(r => r.Columns(true))
.Resizable(r => r.Columns(true))
.ColumnMenu()
.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(500)
    .Read(read => read.Action("_GetForAssessment", "DashBoard"))
    .Events(events => events.Error("error_handler"))
    .Model(model => { model.Id(p=>p.ApplicationId); model.Field(p => p.ApplicationId); })
  .Update(update => update.Action("UpdateLockinProductContents", "PackageContent"))
)
)




[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult UpdateLockinProductContents([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<ModalName> model)
        {}

Upvotes: -1

Related Questions