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

  • SEARCH
  • Home
  • 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 8619155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:16:32+00:00 2026-06-12T06:16:32+00:00

I am using jqGrid for inline editing and also when creating new record with

  • 0

I am using jqGrid for inline editing and also when creating new record with the Add button.

For sake of simplicity, say I have 2 fields

Field1   Field2

I need the following rules

  • If user doesn’t enter anything in Field1 or Field2, no validation if needed
  • If user does enter data, they can enter it in either Field1 or Field2 but not both
  • 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-06-12T06:16:34+00:00Added an answer on June 12, 2026 at 6:16 am

    The validation possibilities of jqGrid has many restrictions especially validation during inline editing. The method $.jgrid.checkValues, which implements the validation will be called (see the line of source code), will be called directly during reading of the corresponding input field. So one have no information about other fields as the current validating.

    As the workaround you can save the value from the Field1 during the field validation. The validation of the Filed2 can do the validation of the both fields. The custom validation is the way which you can use in the case.

    var field1, field2,
        myCustomCheck = function (value, colname) {
            if (colname === "field1") {
                field1 = value;
            } else if (colname === "field2") {
                field2 = value;
            }
    
            if (field1 !== undefined && field2 !== undefined) {
                // validate the fields here
                return [false, "some error text"];
            } else {
                return [true];
            }
        };
    
    $("#grid").jqGrid({
        ...
        colModel: [ 
            ... 
            {name: 'field1', editable: true, ...,
                editrules: {custom: true, custom_func: myCustomCheck}},
            ...
            {name: 'field2', editable: true, ...,
                editrules: {custom: true, custom_func: myCustomCheck}},
            ...
        ]
        ...
    });
    

    You should don’t forget to reset field1 and field2 variables to undefined value either before or after editing (in oneditfunc, aftersavefunc or some other callback).

    I used in the above code the “symmetric” version of field1 and field2 validation to make the code working in case of changed order of the fields, which can be important if you use columnChooser. In the case you can’t be sure that field1 will be always validated before the field2.

    Some additional effects you can archive by usage of “subclassing” of existing jqGrid methods. See the answer as an example.

    UPDATED: The demo demonstrate the above idea of the validation more detailed.

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

Sidebar

Related Questions

jqGrid contains quantity column and add to cart button using colmodel below. Inline editing
I have a jqGrid with a list of users in it using inline add/edit
I have a jqGrid (using inline editing) with an autocomplete column. When the user
jQgrid row is edited using inline editing mode. Pressing Enter sends data to server
I have a table using jqGrid, I need that when editing a row some
I'm using jqgrid with inline editing , when the user gets to the last
I'm using jqGrid with inline row editing and I want to let the user
I am using jqgrid and using the inline editing mode and can't figure out
Inline editing is started using edit formatter action button. If clicked in other row,
I'm using jqGrid PHP. When adding a new row (inline mode), how can I

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.