Hello Expert,
I have a grid that allow user to add new row or update data. However, I want the data post to the Server when the 'Done' button on the row is click. In the other word, I don't want batch update. I could not find any example on your website.
Thank you
Hello Phoeng,
Thank you for posting in our community.
By igGrid Updating feature uses transactions to log any changes made to the grid. These transactions are kept locally in the browser until the igGrid.saveChanges method is called to send POST request to the server. In regards to this, what I can suggest for achieving your requirement is handling editRowEnded event of the Updating feature. This event if fired after end row editing. There you could call the saveChanges method. For example:
features: [ . . . { name: "Updating", editRowEnded: function(evt, ui){ $("#grid").igGrid("saveChanges"); }, . . . . } ]
I also believe the you will find the following article from our documentation helpful:
Updating Overview(igGrid)
Please let me know if you need any further assistance regarding this matter.
Thank you for the response. However, I have the Hierarchy grid, and I would like to attach the Event in the Codebehid (Controller). Do you have any idea how to get the Id for the Hierarchy grid and attach the event in the code?
internal static GridColumnLayoutModel CreateAssociatedObjectGrid(string handler_name, string row_id) { // Create associated object grid GridColumnLayoutModel gridLayout = new GridColumnLayoutModel(); // Define parameters gridLayout.Caption = "Notes"; gridLayout.Key = "NoteSid"; gridLayout.PrimaryKey = "NoteSid"; gridLayout.Columns.Add(new GridColumn() { HeaderText = "NoteSid", Key = "NoteSid", DataType = "string" }); gridLayout.Columns.Add(new GridColumn() { HeaderText = "Note", Key = "NoteDescription", DataType = "string" }); gridLayout.AutoCommit = true; // Apply features //GridUiHelper.ApplyFeatures(gridLayout, handler_name, row_id); gridLayout.DataSourceUrl = "some url"; gridLayout.UpdateUrl = "some url"; gridLayout.Features.Add(new GridHiding() { Inherit = true, ColumnSettings = new List<ColumnHidingSetting>() { new ColumnHidingSetting() { ColumnKey = "NoteSid", AllowHiding = false, Hidden = true } } }); gridLayout.Features.Add(new GridUpdating() { EditMode = GridEditMode.Row, ColumnSettings = new List<ColumnUpdatingSetting>() { new ColumnUpdatingSetting(){ColumnKey = "NoteDescription", EditorType = ColumnEditorType.Text, Required = true} } }); // Return finished associated object grid return gridLayout; }
Hello Phong,
I am glad that you find my suggestion helpful.
Please let me know if you need any further assistance with this matter.
Thank you for your code snippet.
What I can say in regards to your query is that you could add a particular event when creating the model for the grid however the function handling this event should be defined in advance. This could be achieve using AddClientEvent method which takes two parameters, event name and the name of the function that is going to be used as an event handler. For example:
model.AddClientEvent(GridClientEvents.CellClick, "gridCellClickHandler");
The gridCellClickHandler is defined in the View as following:
function gridCellClickHandler() { alert("Add your code here"); }
function gridCellClickHandler() {
alert("Add your code here");
}
I hope you find my suggestion helpful.
I am also attaching a small sample illustrating my suggestion for your reference.