Hello,
We need to update a row and send an additional value with it, which is not a column. We're using the method igGrid.saveChanges.
The only way to do this we found so far is to add a hidden column, and set the additional value in it but we don't really like this solution, is there another way of doing it ?
Thanks
Hello Vincent,
Thank you for posting into our community!
I have been looking into your question and an approach I could suggest is using igGridUpdating’s editRowEnding event and declaring a temporary variable where the updated values are assigned to it as well as the additional value. This could look similar to the following:
editRowEnding: function (evt, ui) { var temp = ui.values; temp.Additional = "Add Value"; ui.values = temp; },
Furthermore, you have mentioned that you are using the igGrid’s saveChanges method and this approach is applicable for this case as well since the modified changes performed in the editRowEnding event, i.e., adding the additional value, are sent to the ig_transactions field. This could be observed in the below attachment:
Additionally, I have prepared a small sample demonstrating my suggestion and it could be found here. Please test it on your side and let me know if you need any further assistance regarding this matter.
In case this is not an accurate demonstration of what you are trying to achieve, please feel free to modify it and send it back a long with steps to reproduce.
Looking forward to your reply.
Sincerely, Riva Ivanova Entry Level Software Developer
Hello, thank you for your answer.
It works fine for what we need, but it's only for editMode "row", is there a similar solution when we are in editMode "cell" ?
Thank you for following up!
I am glad that you find my suggestion helpful. Additionally, from your initial message I was under the impression that you require adding an additional value when the edit mode is set to "row". A similar functionality could be achieved when the edit mode is set to "cell" by using, for example, the editCellEnded event and adding an additional property to the record like the following:
editCellEnded: function(evt, ui){ var record = $("#grid").igGrid("findRecordByKey", ui.rowID); record.Additional = "Add Value"; },
This will modify the record to contain the additional "Additional" property with value "Add Value". However, when the edit mode is set to "cell" the generated transactions are only for the updated cells. Having this in mind, in case you require the additional property to be included in the ig_transactions, what I could suggest is calling the updateRow method with the modified record which will create a type "row" transaction which contains all properties for the record including the additional one.
This could be achieved like the following:
$("#grid").igGridUpdating("updateRow", ui.rowID, record);
or by just adding the additional property with its value like the following:
$("#grid").igGridUpdating("updateRow", ui.rowID, { Additional: "Add Value" });
Please test it on your side and let me know if you need any further assistance regarding this matter.