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

Kendo Grid doesn't post changes to controller

1 Answer 422 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jwize
Top achievements
Rank 1
jwize asked on 10 Apr 2013, 07:57 PM
This should be simple
My grid gets the data initially as expected but doesn't do anything when the update button is clicked while adding a new record.
@(Html.Kendo().Grid<DepartmentViewModel>()
      .Name("DepartmentsGrid")
      .ToolBar(t => t.Create().Text("New Department"))
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Columns(columns =>
          {
              columns.Bound(d => d.Name);
              columns.Bound(d => d.Email);
              columns.Bound(d => d.Phone);
              columns.Command(c => c.Edit());
          }).Filterable().Groupable().Sortable().Pageable()
            .DataSource(datasource => datasource
                .Ajax()
                .Events(events => events.Error("error_handler"))
                .Create("CreateDepartment","Admin")
                .Update("UpdateDepartment","Admin")
                .Model(m=> m.Id(id => id.Id))
                .Read(read => read.Action("DepartmentsGridData", "Admin"))))
My server code is here.
public partial class AdminController
   {
       public ActionResult Departments()
       {
           return View();
       }
 
       public ActionResult DepartmentsGridData([DataSourceRequest] DataSourceRequest request)
       {
           var data = _departmentService.GetDepartments();
           var model = data.ToDataSourceResult(request);
           return Json(model);
       }
       [HttpPost]
       public ActionResult CreateDepartment([DataSourceRequest] DataSourceRequest request,Department department)
       {
           return null;
       }
       [HttpPost]
       public ActionResult UpdateDepartment([DataSourceRequest] DataSourceRequest request,Department department)
       {
           return null;
       }
   }
Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 11 Apr 2013, 07:14 AM
Hello Jaime,

 
The Grid configuration seems to follow the guidelines from the help article. The controller configuration for Create action must be updated as in the step 7 from above article. Otherwise the newly added records will always be considered by client DataSource representation as new items.

However if the issue is that your controller is not being hit or no data is send on clicking `Update` button there are few things to check:
 - make sure that there aren't any JavaScript errors in browser console
 - inspect the `Network` tab of the browser console and see whether any data is being send and its format in the request payload.
 - make sure that script files are included in correct order
 

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