Let's see now how to let the user edit our grid.
First of all, we have to set the columns that we want the user to be able to edit, this is done
by the following commands:
g.set_col_editable ( 1, "txt" );
g.set_col_editable ( 2, "txt" );
g.set_col_editable ( 3, "txt" );
Since the last field should contain an e-mail, we can force the user to insert valid chars by
filtering his/her typing against the given string and by adding a field validator:
g.set_col_valid_chars ( 3, "abcdefghijklmnopqrstuvwxyz@.-0123456789_" );
g.set_col_validation ( 3, check_email );
The
check_email is a form validation function defined inside
form_validators.js.
This file contains many more pre made validators, take a look at it and, if you are using it, do
not forget to add the JavaScript file in your document with the following code:
<script src="form_validators.js" type="text/javascript"></script>
If we want the grid rows to be automatically resorted when the user changes grid contents, simply
set this flag to true:
That's all! The final result is shown below.