To solve this problem, we thought it was easy to use canceledit. Who knows it's not that easy.
It is said that the function execution sequence is:
Reprinted from: http://dangfang800.blog.163.com/blog/static/32243525200781695130664/
The following lists the order of events such as validation, enter/leave, and begin/end (when editmode is editonenter ):
When moving from one cell to another(In the same row):
1) cell leave (original cell)
2) cell validating/ED (original cell)
3) cell endedit (original cell)
4) cell enter (new cell)
5) cell beginedit (new cell)
When moving from one row to another:
1) cell leave (original cell) and row leave (original row)
2) cell validating/ED (original cell)
3) cell endedit (original cell)
4) Row validating/ED (original row)
5) Row enter (new row)
6) cell enter (new cell)
7) cell beginedit (new cell)
Then, if the verification fails in cell leave, validating, and validated, canceledit will fail! The values in these functions are the values before modification.
So the solution is:
Use cell endedit and record the values before modification in cell leave or validate. If the verification fails, it will be restored in endedit. In this way, another member of the class is added ~
I wonder if there are any other better solutions?