I am using the igGrid with a web API that saves changes similar to the way an MVC controller does. I have confirmed that the data from the igGrid is sent to the web API correctly (it is actually saved to the database). The only remaining problem is that the grid still shows deleted rows with a strikethrough and added/modified rows in italics.
Here's the JavaScript for the igGrid:
$("#grid1").igGrid({ dataSource: "/api/processes", updateUrl: "/api/processes/save", primaryKey: "processID", autoGenerateColumns: false, height: "350px", width: "800px", columns: [ { headerText: "Process ID", key: "processID", dataType: "number" }, { headerText: "Name", key: "name", dataType: "string" }, ], features: [ { name: "Updating", editMode: 'cell', columnSettings: [{ columnKey: 'processID', readOnly: true }] } ] });
And here is the response I'm returning from my web API:
JsonResult result = new JsonResult(); Dictionary<string, bool> response = new Dictionary<string, bool>(); response.Add("Success", true); result.Data = response; return result;
The result translates to this JSON: {"data":{"Success":true},"jsonRequestBehavior":"DenyGet"}
I also tried returning {"Success":true}
My question is: What should I return from the web API to tell the igGrid that data was saved successfully so it will make deleted rows disappear and turn off italics on added and modified rows?
Thanks in advance.
Hello Harry,
If you have any further questions don’t hesitate to contact us again.
Thanks for the quick response. I just tried that and I get the same result...wait....ah, there it is. I'm using ServiceStack for the web API. ServiceStack services return human readable HTML by default. Told it to return JSON and it works like a charm now. [I did try that earlier but not with your suggestion.]
Good way to start the day. Thanks!
Hello,
When using WebAPI you shouldn't wrap your response in an ActionResult derivative. Try returning the dictionary directly:
public Dictionary<string, bool> Post() { Dictionary<string, bool> response = new Dictionary<string, bool>(); response.Add("Success", true); return response; }
Hope this helps! Please, let me know if you have any other questions and/or concerns!
Best regards,
Stamen Stoychev