I have just started using phpgrid – which I may add is extremely easy to use.
I have tested with 2 users making changes to the same data retrieved – user 1 makes a change, followed by user 2 making a different change. Using phpGrid without any changes, User 2's change wins and is saved.
My question is:
Is there a way to configure phpGrid to do a SELECT to the database with ALL the current row fields data before an update occurs to ensure another user's changes are not overwritten?
Ideally – when a save of already updated data (by another user) is attempted, an alert will appear to indicate this happening, and the grid will be refreshed to display the updated data.
Thank You
Hello Paul,
First solution is to use excel-view (cellEdit) mode. In this way, only the changed cell is submitted to server and not the whole row data. You can refer demos/appearence/excel-view.php for working demo.
Second, If you want application based row level locking in grid:
1) Introduce a new field 'last_modified', make it hidden on grid and editable. It will store the timestamp of row update.
2) Implement an on_update event handler and check if:
i) Fetch the edited row db table row, using select query
i) Check if posted back 'last_modified' value is different from the one in database against same row id
ii) If Yes, You can show phpgrid_error('Already edited') otherwise, go with the update.
I've also prepared a demo for you: http://pastebin.com/Ds4WrD4z