Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1032001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:01:08+00:00 2026-05-16T14:01:08+00:00

I have a GridPanel with just two columns: names and commission percentages. The sum

  • 0

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%)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:01:08+00:00Added an answer on May 16, 2026 at 2:01 pm

    I didn’t quite use js1568’s answer, as I wanted to block bad values as they’re being entered; even before the AfterEdit event fires and the row gets marked dirty, and long before writing to the database. But that link did inspire me through its use of the grid’s selection model. So, my quick little solution:

    Because the NumberField doesn’t pass any context to the custom validator (aside from the current value), using field.originalValue would have been awesome, but hey, life is hard.

    But due to the fact that editing a row first requires selection of that row (and reinforced by the fact that this grid’s RowSelectionModel is set to SingleSelect), I know that the row being edited must be the only element in grid.selModel.selections.items[]. From there, it’s just a matter of

    var newTotal = TotalCommissionPercentagesInGrid() – oldValue + newValue;
    

    With oldValue being grid.selModel.selections.items[0].data.CommissionPercentage and newValue being the value passed to the validator function from the NumberField.

    return ( newTotal <= percentageAvailable ) ? true : "No dice.";
    

    Very nice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridPanel which should load a maximum number of resources. If there
Using 4.0.6 I have a gridpanel with an actioncolumn that has two items, a
I have GridPanel with toolbar on it with many buttons. All buttons can't stand
I have an ext js grid like below: var grid = new Ext.grid.GridPanel({ columns:
i'm new with extjs4, i have a problem with gridpanel that should be show
I have GridPanel with 2 columns : Type : string Details : combo I
I have a gridPanel with ColumnModel . One of this columns is ActionColumn with
I just noticed that EditorGridPanel doesn't have row over effect as in GridPanel so
In extjs I have a GridPanel. The GridPanel has some hidden columns. Now when
I have this ASP code: <ext:GridPanel ID=grid> <ColumnModel runat=server> <Columns> <ext:RowNumbererColumn /> <ext:Column Align=Center

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.