dhtmlxGrid can integrate with a surrounding FORM - which means grid data will be sent as a part of form submitting (this functionality can be used to save changes in the grid, if you do not want to use dataprocessor library).
To enable form integration you need:
That is all, no additional steps are to be taken.
Grid can work in the following modes:
Submit only the changed rows is the default mode. In this mode the grid will include only the data of the changed rows in the process of form submitting.
For each changed row a virtual input field will be added:
The name of the field is [GRIDID]_[ROWID]_[CELLINDEX]
where
The value of the field is equal to the cell value.
For example, if we have a grid similar to the following one:
var grid = new dhtmlXGridObject("gridbox") ... grid.addRow("r1",["first","second","third"])
And later change the “second” to the “new second” and submit a form, it will have a
gridbox_r1_1=“new second”
If any row was added to the grid, all values of this new row will be marked as changed. Additional to it the
[GRIDID]_ROWS_ADDED
virtual input will be added. It will contain the list of IDs of the added rows (so on the server side it will be possible to separate added and updated rows).
If any row was deleted, the
[GRIDID]_ROWS_DELETED
virtual input will be added. The same as for the added rows, it will contain the list of IDs of the deleted rows.
Sending the information about added|deleted rows is enabled by default, but can be disabled in the following way:
grid.submitAddedRows(false);
It is a mode that is not going to be used quite often, in my opinion. It can be enabled by:
grid.submitOnlyChanged(false);
In this mode a virtual input field for each cell will be created in the grid .
In this mode the grid will create a single virtual field: [GRIDID]_SELECTED This field will contain a list of row IDs which are selected (in the single select mode - it will be a single ID). The mode can be enabled by:
grid.submitOnlySelected(true) grid.submitOnlyRowID(true);
This mode works almost in the same way as the default mode. This mode will send updated values from the selected rows only:
grid.submitOnlySelected(true); grid.submitOnlyRowID(false);
You can mark any row in the grid as updated in the following way:
grid.cells(i,j).cell.wasChanged=true;