example php update database with changed grid information
Hello,
I was searching through the forum, looking for an example how to update the changed information in the grid to the MySQL database.
There was a nice example how to do this using the updateSingeCell.php example.
However, this updates the changed information without giving the user the chance to choose. And you must have a second page that handles the posted information.
So I took some information I found in the forums and wrote a nice example how to update the information after clicking a save button.
This is something many users of AW-grid are looking for, so I hope this will help you a lot.
When a user clicks a save button, through javascript we check first if something has been changed. If not, an alert is raised, to inform the user that nothing has been changed.
If something has been changed, the user gets a question if he wants to save the changes or not. Only if he presses yes, the information is posted to the server.
In fact, it's very simple.
We create an empty javascript array. If a cell is changed in the grid, this information is stored in the array. When the user wants to save the information, this javascript array will be transformed into a hidden form. The elements in the array will be hidden fields. This form will then be posted to the same page, so you can use the posted information like you are used to do with a normal form.
The advantage is that the hidden form is created on the clients pc, so it goed fast and only the updated rows are posted, not the complete grid.
To make it easy, you can download the sample trough : http://applications.softswoon.com/aw/demo_update_grid.zip
Also the sql file is included, to create the demo database that is used in the example.
Have fun with it.
Dries GERIS
I was searching through the forum, looking for an example how to update the changed information in the grid to the MySQL database.
There was a nice example how to do this using the updateSingeCell.php example.
However, this updates the changed information without giving the user the chance to choose. And you must have a second page that handles the posted information.
So I took some information I found in the forums and wrote a nice example how to update the information after clicking a save button.
This is something many users of AW-grid are looking for, so I hope this will help you a lot.
When a user clicks a save button, through javascript we check first if something has been changed. If not, an alert is raised, to inform the user that nothing has been changed.
If something has been changed, the user gets a question if he wants to save the changes or not. Only if he presses yes, the information is posted to the server.
In fact, it's very simple.
We create an empty javascript array. If a cell is changed in the grid, this information is stored in the array. When the user wants to save the information, this javascript array will be transformed into a hidden form. The elements in the array will be hidden fields. This form will then be posted to the same page, so you can use the posted information like you are used to do with a normal form.
The advantage is that the hidden form is created on the clients pc, so it goed fast and only the updated rows are posted, not the complete grid.
To make it easy, you can download the sample trough : http://applications.softswoon.com/aw/demo_update_grid.zip
Also the sql file is included, to create the demo database that is used in the example.
Have fun with it.
Dries GERIS
Dries GERIS
August 17,