Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
960
igGrid - transactions remain even after commit
posted

Hi

ignite ui 13.1 with ASp.NET MVC site

Imagine that I am going to load the page, add a row to the grid, save the changes and then edit a different row in the grid.

I am using an igGrid and I am saving the changes via an explicit Ajax post, which calls an action method in my MVC controller and passes the grid transactions across as a property of the view model.

Here is a snippet from my save button click function:

			var transactions = JSON.stringify($("#ProductGrid").igGrid("allTransactions"));
			var form = $('form').serialize(); // Serialize form data.
			var data = { __RequestVerificationToken: $('[name=__RequestVerificationToken]').val(), ig_transactions: transactions, formData: form }; // Format it for our model.
			// Post to the server.
			$.post(url, data, changesSuccessHandler);

When the post completes is calls the java function changesSuccessHandler and in that function I commit the changes:

			$("#ProductGrid").igGrid("commit");

So far so good. This works fine - my new row loses its italics and all looks good.


The bit that baffles me is that if I then go on to edit a different row and save again the original newrow transaction is still present in the grid. This results in an attempt to add the same new row again, which leads to duplicates in my DB.


I thought that commit would commit the changes and remove the transactions, is there something else that I should be calling to really get rid of the now saved transactions?
I don't want to dataBind as that will get all the data from the server again and there is no need for this round trip. I just need to remove the transactions so that I only get changes made since the last commit the next time I ask for the grid's transactions.


Regards,
Graeme