Using the latest version of IgniteUi.
I'm using iGrids saveChanges ajax functionality to httppost transactions to an mvc controller.
As per documentation and examples the return type of the controller is "ActionResult" however the return is a Json response.
On its way out when the code reaches the OnActionExecuted I get an error inside the GridDataSourceActionAttribute class on line 146 - Object reference not set to an instance of an object.
Here are some snippets of code.
My success response being returned from the controller with the Action Attribute.
JsonResult result = new JsonResult(); Dictionary response = new Dictionary(); response.Add("Success", true); result.Data = response; return result;
The setup of my iGrid
@(Html.Infragistics() .Grid() .ID("MoviesGrid") .PrimaryKey("ID") .AutoCommit(true) .RenderCheckboxes(false) .Features(features => { features.Sorting().Type(OpType.Local).Mode(SortingMode.Single); features.Updating(); features.Filtering(); }) .DataSource(Model.Movies) .DataSourceUrl(Url.Action("GetMoviesDataAction", "Movies")) .UpdateUrl(Url.Action("UpdateMovieRecords")) .AggregateTransactions(true) .DataBind() .Render())
Hi Jagdip Singh,
The grid does not automatically call saveChanges. We leave that up to you to decide when you want to send the information to the server. For updating the server after the user finishes editing a row, your solution is what we usually recommend. You may also want to call saveChanges during the rowAdded and rowDeleted events.
If you have any further questions or concerns with this, please let me know.
Hello Michael,
Thanks for getting back to me. What I'm trying to do is once the grid has been changed i.e. a row has been edited, added or deleted then the iGrid should do a post to the controller for it to then input those changes into the db. I've set up the UpdateUrl for the iGrid setup with the controller action that should expect this post/change and nothing happens.
Therefore the issue is, I'm having to do it manually using saveChanges hooking onto the events.
E.g.
$(document).delegate("#MoviesGrid", "iggridupdatingeditrowended", function (evt, ui) { $("#MoviesGrid").igGrid("saveChanges", function(data) { ... }, function(jqXHR, textStatus, errorThrown) { ... }); });
Is there a better way that I should be doing this?
This is in an MVC 5 Entity Framework scenario.
Kind regards
For the saveChanges actions, the GridDataSourceActionAttribute should not be used. The GridDataSourceActionAttribute is meant to take the model data and convert it to JSON in the response for the igGrid to bind to. The igGrid is not expecting to receive new data when saveChanges is called. You can find an example of using a saveChanges action in our documentation here.
If you need to refresh the grid's data after calling saveChanges, it is recommended to make a separate dataBind call on the grid.
If you have any further questions or concerns with this, please let me know and I will be glad to help.
Hello Jagdip Singh,
Thank you for posting in our forums!
I am able to reproduce the exception and am discussing this further with the grid's development team for their input.
I will have more information for you when I hear back from them. If you have any further questions or concerns with this issue, please let me know.