by
Allistar Melville >> Wed, 11 Nov 1998 16:32:10 GMT
Not at all. You just have to be clever in how you code the
keyPress/Down method. (e.g "-" is only valid as a first character, "."
is only allowed once etc). This way means that the overhead happens
when the user strikes the key, and the overhead is very small (a few
if statements should do it).
I think that preventing the user from entering invalid data is by far
the best policy.
Using the Jade built in isDecimal method on the entire entered string
would appear to be the best way as it handles decimal fractions as well as whole
numbers. That would leave the question of whether you do the isDecimal test every time a key stroke is entered into the cell or only when you are ready to
update the database.
Doing it on every keystroke seems like a bit of an overkill (although admittedly the isDecimal() test wouldn't slow it down much, if any).
I have sometimes used the technique where the data entered into a cell is checked only when another cell is selected or the table control loses the focus. This means the user can type any rubbish they like
into a cell but will get pulled up if they try to move to another cell or control.
We use this technique also (not for decimal validation, though). If
the user is in a decimal cell and they enter "23", when they move out
of that cell it's contents becomes "23.00", which makes everything
look nice :-p.
We have noticed that jade gives you no way of selecting the contents
of a cell when you move into it (which makes fast data entry into a
table a real pain as the user has to delete the contents of the cell
out first).
Our way of combatting this was to subclass the Table control and reimplement the way input types are handled. Essentially we don't let Jade control the InputType_TextBox cells as we actually place a text
box control on the cell instead. As far as the user is concerned
nothing has changed, but we now have nice features like selecting the contents of the cell when you move into it (this is also the way we
got around the above decimal validation problem).
Allistar.
------------------------------------------------------------------
Allistar Melville (BSc) Home:
allistar@ihug.co.nz \_
Software Developer Work:
allistar@focussoft.co.nz </'
Auckland, NEW ZEALAND /)
Web:
http://homepages.ihug.co.nz/~allistar/ (/`
`
"A wise man proportions his belief to the evidence." David Hume ------------------------------------------------------------------