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!
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.
I was wrong, I found that autocommit actually doesn't clear the transactions log, but this does it:
var _response = new Dictionary<string, bool> { { "Success", true } };
Change it to false and that will not clear the transactions log.
var _response = new Dictionary<string, bool> { { "Success", false } };
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. ;)
This person (http://es.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?
Thank you for the video Kolev! I see that you use the Done/Cancel dialog, but I want to let users to change data then commit all changes without having to press on that dialog. My grid pretend to show a few of rows with checks, that is the only cell that user can edit, so it is not nice if users have to press Done on every row. I know the problem is with the last row as you can see in my video, it is never commited. That's why I want to force the commit with AutoCommit or with $("#MyGrid").igGrid("commit"). How to do that? I mean, AutoCommit or "commit" is not working in my case.