Hey everyone,
I have an issue with my Data Source that when I post, it's not updating the Data Source's entity with the new ID that is created on the server side. What then happens, is any other post I make sends multiple posts. The second time I post, it sends two posts, the third time, three posts, etc. I have look through the forum post here:
http://www.telerik.com/forums/kendo-ui-grid-inserts-updates-create-duplicate-records#2063733
And I'm having the same issue. I am returning the Id of the newly inserted record, and it's even saving out to the SQL data base.
I'm using ASP.NET WebAPI Odata controllers. The controller looks like this:
// POST: odata/Actionspublic IHttpActionResult Post(TNYData.Action action) { if (!ModelState.IsValid) { return BadRequest(ModelState); } action.Created = DateTime.Now; action.CreatedBy = User.Identity.Name; action.Modified = DateTime.Now; action.ModifiedBy = User.Identity.Name; db.Actions.Add(action); db.SaveChanges(); return Created(action); }The Data Source looks like this:
actionDataSource: new kendo.data.DataSource({ type: "odata-v4", autoSync: true, transport: { read: { url: config.apiBasePath + "Actions", dataType: "json" }, create: { url: config.apiBasePath + "Actions", dataType: "application/json", beforeSend: function(req) { req.setRequestHeader('Authorization', sessionStorage.getItem("tnyApiKey")); } } }, schema: { data: kendo.data.schemas["odata-v4"].data, total: kendo.data.schemas["odata-v4"].total, model: { id: "Id", fields: { Id: { //this field will not be editable (default value is true) editable: false, // a defaultValue will not be assigned (default value is false) nullable: true }, Name: { validation: { required: true } }, Description: { validation: { required: false } } } } } })The response JSON look like this:
{ "odata.metadata":"http://localhost:64533/odata/$metadata#Actions/@Element","Id":367,"Name":"New Item","Description":null,"Created":"2015-06-28T19:37:14.9379909-04:00","Modified":"2015-06-28T19:37:14.9379909-04:00","CreatedBy":null,"ModifiedBy":null,"StartDate":null,"DueDate":null,"Flagged":false}I get no errors in Chrome console, IE, or Visual Studio.
What am I missing here?