This is a migrated thread and some comments may be shown as answers.

[Solved] Popup Update / Save is not working with MVC

1 Answer 372 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 1
Veteran
Iron
Kiran asked on 10 Jan 2015, 07:21 PM
 I am trying to save the modified changes from kendo ui grid, but its not hitting the controller method. Here is my view code,

@(Html.Kendo().Grid(Model.BisStudentModel)
 .Name("grdStudent")
 .Columns(columns =>
 {
 columns.Command(cmd => cmd.Edit());
 columns.Bound(c => c.ContractNumber).Title("Contract No.").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(60))).Width("30%");
 columns.Bound(c => c.TeacherLastName).Title("Last Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(80))).Width("30%");
 columns.Bound(c => c.TeacherFirstName).Title("First Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(80))).Width("30%");
 columns.Bound(c => c.SchoolCode).Title("School Code").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(60))).Width("30%");
 columns.Bound(c => c.SchoolId).Title("School ID").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(60))).Width("30%");
 columns.Bound(c => c.EducationLevel).Title("Education Level").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(60))).Width("30%");
 columns.Bound(c => c.StudentLastName).Title("Student Last Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(80))).Width("30%");
 columns.Bound(c => c.StudentFirstName).Title("Student First Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(80))).Width("30%");
 columns.Bound(c => c.StudentSsn).Title("SSN").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(60))).Width("30%");
 columns.Bound(c => c.StudentStn).Title("STN").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(70))).Width("30%");
 columns.Bound(c => c.ClockHoursofStudent).Title("Clock Hrs.").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").InputWidth(70))).Width("30%").Format("{0:n2}");
  
 })
.HtmlAttributes(new { Style = "height:500px" })
.Sortable()
.Pageable(pager => pager.PageSizes(new int[] { 10, 20, 50, 100 })
.ButtonCount(20))
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.DataSource(dataSource => dataSource
.Ajax() 
.Model(model => model.Id(m => m.BisEnrollment))
.Destroy(destroy => destroy.Action("Products_Destroy", "EnrollmentViewEdit"))
.Update(up => up.Action("SaveBisStudentClassdata", "EnrollmentViewEdit").Type(HttpVerbs.Post)))
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("_StudentEditor").Window(w => w.Title("Edit " + Model.HeaderLabelText).Width(1200))
 ))
 
 And my update actionmethod in the controller is,
 
  public ActionResult SaveBisStudentClassdata([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]  IEnumerable<StudentDataModel> studentDataModels)
   {
if (studentDataModels != null && ModelState.IsValid)
{
var model = studentDataModels[0];
var studentDataModel = new StudentDataModel
{
BisEnrollment = model.BisEnrollment,
ContractNumber = model.ContractNumber,
StudentFirstName = model.StudentFirstName,
StudentLastName = model.StudentLastName,
StudentSsn = model.StudentSsn,
StudentStn = model.StudentStn,
SchoolId = model.SchoolId,
SchoolCode = model.SchoolCode
};
var result = _eApiClient.UpdateStudentData(StudentDataModel).Result.StudentFileEnumerable;
       }
       
return Json(new[] { studentDataModels }.ToDataSourceResult(request, ModelState));
    }

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 13 Jan 2015, 08:59 AM

Hello Kiran,

The current update action is configured for Batch edit mode, in which case multiple edited items are posted at once. You could check the correct approach for InLine/PopUp edit modes at the following documentation page.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Kiran
Top achievements
Rank 1
Veteran
Iron
Answers by
Dimiter Madjarov
Telerik team
Share this question
or