Version 2014.1
MVC 5
I have a a grid with updating enabled. I have AutoCommit enabled on the grid as well. however when I click the Done button when editing or adding or when I delete a row, I would expect the UpdateURL action to be executed but it is not. According to the doumentation located at http://help.infragistics.com/Doc/jQuery/Current/CLR4.0?page=igGrid_Updating.html which reads "If autoCommit is enabled, the edit row actions trigger updates in the data source." it seems to indicate that when AutoCommit is enabled the UpdateURL action shoudl be fired.
here is the Helper
@(Html.Infragistics().Grid(Model) .ID("contactGrid") .PrimaryKey("ContactID") .AutoGenerateColumns(false) .Columns(columns => { columns.For(item => item.ContactDescription).HeaderText("Contact Description"); columns.For(item => item.ContactID).Hidden(true); }) .Features(features => { features.Sorting().FirstSortDirection("ascending").Mode(SortingMode.Single); features.Filtering().Mode(FilterMode.Advanced).FilterDropDownItemIcons(true); features.Paging() .ShowPageSizeDropDown(true) .PageSizeDropDownLocation("inpager") .PageSizeList(new List<int> { 10, 20, 30, 40, 50 }) .PageSize(10) .FirstPageTooltip("Move to the First page") .LastPageTooltip("Move to the Last Page"); features.Updating() .EditMode(GridEditMode.Row) .EnableAddRow(true) .EnableDeleteRow(true) .ShowDoneCancelButtons(true) .StartEditTriggers(GridStartEditTriggers.DblClick | GridStartEditTriggers.Click) .ColumnSettings(settings => { settings.ColumnSetting() .ColumnKey("ContactDescription") .EditorType(ColumnEditorType.Text) .Required(true); settings.ColumnSetting() .ColumnKey("ContactId").ReadOnly(true); }); }) .AutoCommit(true) .UpdateUrl(@Url.Action("UpdateContactOptions")) .DataSourceUrl(Url.Action("RetrieveContactOptions")) .DataBind() .Render())
I believe this is a bug.
That said I am now attempting to turn off autoCommit and handling the various events to call saveChanges manually, however I need to know what events are the right ones to handle. I have event handlers rowAdded,editRowEnded,rowDeleted currently. The issues I am having with these are as follows:
editRowEnded fires regardless of whether I click cancel or done,
when adding a new row both rowAdded and editRowEnded fire causing the UpdateURL to be hit twice.
I saw references to a rowUpdated event in some forum posts but cannot find that in any documentation.
Hello Chris,
The autoCommit option refers to committing the transactions on the client and therefore differs from invoking the saveChanges methods which commits the transactions to the controller method. I am currently researching your scenario to determine the best approach to invoke saveChanges after any change and will keep you posted of my progress.
In order to determine whether an update has occurred it should be enough to handle only theeditRowEndedevent and check whether either theupdateandrowAddingproperties of the event argument are true:
editRowEnded: function(evt,ui) { if(ui.update || ui.rowAdding) { $("#grid").igGrid("saveChanges"); } }
Hope this helps. Please feel free to contact me with any questions.
Please do not hesitate to contact me if you have any questions regarding this matter.
I had the same question and this thread helped me.
Followup question: how would I handle save errors with this approach? I can display the error to the user, but now we have a committed row in the grid that was not saved.
Things I'm considering trying: add a css class to the row to visually show that it errored; returning the user to edit mode somehow; using editRowEnding event instead.
The problem with using editRowEnding is that the saveChanges method is asynchronous so we can't return false to cancel the event.
I'm not sure the css approach will work correctly either. Let's say the user gets such an error. They will presumably edit the row and try to save again. This would probably work if the original edit was to an existing row, but if it was a new row being inserted, I think the second edit will look like an update rather than a create. (Note that I'm using the grid with jQuery, not MVC, but I think the question applies equally to both environments.)
Suggestions?