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.
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
This is almost fantastic...but not quite.
My data row has a date column in it. When I get allTransactions that date looks like this:
"/Date(1391126400000)/"
This desearialies just fine as it is a valid JSON date format.
In pendingTransactions it is an entirely different format:
"2014-01-31T00:00:00.000Z"
..which I can't then deserialise as a JSON date in my C# MVC Controller action method.
It'd be really great if the pendingTransactions and the allTransactions used the same format for dates!
If it weren't for the date issue I think that pendingTransactions is the way to go. In the mean time other enquiries have revealed the igGrid("allTransatcions").pop() method which will get rid of all transactions, effectively resetting my grid, which will do what I need for this scenario.
Regards,
Graeme
Hi Graeme,
Thank you for posting on our forums.
According to our API documentation (Link), the allTransactions method returns a list of all transaction objects that are either pending, or have been committed in the data source. I believe what you want to use is the pendingTranscations method (Link), which retruns a list of all transaction objects that are pending to be committed or rolled back to the data source.
Please let me know how this works for you.