I have a GridPanel with just two columns: names and commission percentages. The sum of all of the percentages should never exceed a predetermined maximum (say that 25% of the sale is up for grabs).
Name Commission
Bob 10%
Sally 15%
(Maximum is 25%)
Everything is fine.
I’ve attached a custom validator (see "validator") to the NumberField editor which works just great for complex logic on individual values, and I can sum up all of the values for the number column in the data store easily. But the problem is combining the two; the new value isn’t pushed to the store until after a successful validation, and the custom validator is only given the current value in question, with no context as to what row is involved (with which I could potentially subtract the old value, and use this new value in the total).
How can I get this validator to work in such a way that it makes sure that a newly entered value doesn’t push the sum over the maximum?
Name Commission
Bob 10%
Sally 16% (Invalid! Total commissions must not exceed 25%)
(Maximum is 25%)