In the next action result _transaction.row is always null, this piece of code is very similar to the one found in http://help.infragistics.com/Help/Doc/jQuery/2013.1/CLR4.0/html/igGrid_Updating.html#column_settings_editors
public ActionResult UpdatingSaveChanges() { ViewData["GenerateCompactJSONResponse"] = false; var _gridModel = new GridModel(); var _transactions = _gridModel.LoadTransactions<MyRowItem>(HttpContext.Request.Form["ig_transactions"]);
foreach (var _transaction in _transactions) { // _transaction catch all the transactions correctly but, // _transaction.row IS ALWAYS NULL, WHY?
if (_transaction.row.IsOk != null) { // Do something here. } }
var _result = new JsonResult(); var _response = new Dictionary<string, bool> {{"Success", true}}; _result.Data = _response; return _result; }
See the attached source code (TestSolution.rar), I have it in a Visual Studio 2013 solution for a MVC 4 demo with Infragistics 2014.1.
I can see all the transactions made in the client side but _transaction.row is always null, what's wrong here?
Hello Luis,
Thank you for contacting us and for the provided sample!
About your question, this is happening because you need to set GridEditMode to be Row, and not Cell. Please make this change and observe how now "row" wont be empty.
Code snippet:
.Features(pFeatures => pFeatures.Updating().EnableAddRow(false)
.EnableDeleteRow(false).EditMode(GridEditMode.Row))
Screenshot:
Fantastic, that worked! :) Now, two more questions:
1) how do I hide the Done/Cancel dialog?
2) how to submit the last change in the grid when the user press submit button. I have noticed that if for example you edit one row, then go to another row (at this moment the first edited row becomes italic) and edit a cell then press Submit button, the last change is not part of the transacctions.
Thank you so much guy, you saved my life!
Hi Kolev, I've tried your advice too but didn't work:
<script>
$("#saveChanges").bind({ click: function (e) { $("#MyGrid").igGrid("commit"); $("#MyGrid").igGrid("saveChanges"); } });
</script>
Any idea?
AutoCommit and Commit() are working, but the only commit the changes locally, this meats that they will fire grids client updating events, but not your UpdateURL action method.
About the issue, I have tested this scenario on my side, and everything works as expected, I mean when I edit two rows and hit "Submit" I have two transactions for each update of row. Please see the image below.
Looking forward to hearing from you.
This person (http://ko.infragistics.com/community/forums/p/84236/421454.aspx#421454) was facing a similar problem. Now I remember that this happens with UltraWinGrid and UltraWinToolbars too, when the user press a tool in the toolbar the grid doesn't lose the focus because toolbars doesn't get focus, so the edited row is not commited. I had to force an update on the last edited row like this:
if( m_MyGrid.ActiveRow != null ){ m_MyGrid.ActiveRow.Update(); m_MyGrid.PerformAction( UltraWinGrid.UltraGridAction.ExitEditMode );}
I am guessing that something similar occurs with igGrid, that's why Done/Cancel dialog is useful, it performs a commit (well, that's what I understand). But in my case I don't want to use Done/Cancel, so the question is, how to force a commit over the last edited row on igGrid? Is there any other way?
Well, after some searching I found it, igGridUpdating makes the magic:
$("#saveChanges").bind({ click: function (e) { $('#MyGrid').igGridUpdating('endEdit', true); $("#MyGrid").igGrid("saveChanges"); } });
I realize that auto commiting is not what I really wanted because that clears the log of transactions in the client side and I want to manage batch updating. So, for now I have what I need. ;)
I am glad to hear this. Thank you for sharing your findings with us, I think that all other community members will benefit a lot from them.