Hi,
We are using KendoGrid in "inCell" mode with "Batch" mode enabled and according to telerik examples we've created our model like following :
Then I've create my BLL as following :
and my controller as following :
and this is my view :
yet when we try to update the data inside the Grid the Update method will get null value for it's second argument (IEnumerable<ASoratModel> asorats) but when we omit the IEnumerable<T> we only get one item.
we want need to get collection of all items when they are updated for showing them correctly in the Grid.
We are confused since we can't find any clue where are we doing wrong.
One thing to note : we don't have any ViewModel class it is all we have that I've copied here.
We are using KendoGrid in "inCell" mode with "Batch" mode enabled and according to telerik examples we've created our model like following :
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace webArta.Models{ public class ASoratModel { public long id { get; set; } public String name { get; set; } public String title { get; set; } }}Then I've create my BLL as following :
using System;using System.Collections.Generic;using System.Data;using System.Data.SqlClient;using System.Linq;using System.Web;namespace webArta.Models{ public class ASoratService { private String sqlCnStr = functions.GetConnectionString(false); public List<ASoratModel> Read() { List<ASoratModel> data = new List<ASoratModel>(); using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand("select * from [test]", connection)) { using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { ASoratModel m = new ASoratModel(); m.id = (long)reader["id"]; m.title = (string)reader["title"]; m.name = (string)reader["name"]; data.Add(m); } } } } return data; } public void Create(ASoratModel model) { model.name = ""; model.title = ""; String sql = "INSERT INTO [test] (name,title) VALUES ('" + model.name + "','" + model.title + "')"; using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.ExecuteNonQuery(); } } } public void Update(ASoratModel model) { String sql = "update [test] set name='" +model.name+"',title='"+model.title+"' where id="+model.id; using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.ExecuteNonQuery(); } } } public void Delete(ASoratModel model) { } }}and my controller as following :
public ActionResult Read([DataSourceRequest] DataSourceRequest request) { return Json(aSoratService.Read().ToDataSourceResult(request)); } [AcceptVerbs(HttpVerbs.Post)]
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Update([DataSourceRequest] DataSourceRequest request, IEnumerable<ASoratModel> asorats){ foreach(var item in asorats) { aSoratService.Update(item); } return Json(asorats.ToDataSourceResult(request,ModelState)); } and this is my view :
@using webArta.Models@using System.Linq@using System.Data @(Html.Kendo().Grid<webArta.Models.ASoratModel>() .Name("grid") .Columns(columns => { columns.Bound(p => p.name); columns.Bound(p => p.title); //columns.Command(c => //{ // c.Edit(); // c.Destroy(); //}); }) .ToolBar(t => { t.Save(); t.Create(); }) .DataSource(dataSource => dataSource .Ajax() .AutoSync(true) .Batch(true) .Model(m => m.Id(p => p.id)) .Read(r => r.Action("Read", "MY_CONTROLLER")) .Create(update => update.Action("Create", "MY_CONTROLLER")) .Update(update => update.Action("Update", "MY_CONTROLLER")) .Destroy(update => update.Action("EditingInline_Destroy", "MY_CONTROLLER")) .ServerOperation(true) ) .Navigatable() .Pageable() .Sortable() .Editable(ed => { ed.Mode(GridEditMode.InCell); ed.CreateAt(GridInsertRowPosition.Bottom); }) .Scrollable() .Filterable() .Resizable(resize => resize.Columns(true)) )yet when we try to update the data inside the Grid the Update method will get null value for it's second argument (IEnumerable<ASoratModel> asorats) but when we omit the IEnumerable<T> we only get one item.
we want need to get collection of all items when they are updated for showing them correctly in the Grid.
We are confused since we can't find any clue where are we doing wrong.
One thing to note : we don't have any ViewModel class it is all we have that I've copied here.

