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 5949417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:14:49+00:00 2026-05-22T17:14:49+00:00

I am using jqgrid inline editing with validation in grid using edit rules .

  • 0

I am using jqgrid inline editing with validation in grid using edit rules . i want to add class to highlight errors(eg: ui-state-error) for the input which fails in validation .
i can set class to highlight error using this

jQuery(‘#’+grid_id).jqGrid(‘setCell’,row_id,errfields[a],”,’ui-state-error’,{color: ‘blue’});

But it is not working in jqgrid when inbuilt validation fails .
How do i highlight the validation error triggered cell/input .

  • 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-22T17:14:50+00:00Added an answer on May 22, 2026 at 5:14 pm

    The demo shows how the probelm can be solved:

    enter image description here

    In the demo the columns “Amount”, “Tax” and “Total” will be validated with the following validation rule:

    editrules:{required:true,number:true}
    

    On any validation error the first input field where the validation failed dditional class “ui-state-error” will be added. It is the standard jQuery UI CSS class. Addionally I set focus to the input field.

    For the implementation I overwride (chain) the default implementation of the methods $.jgrid.checkValues and $.jgrid.hideModal. Here is the corresponding code:

    var grid = $("#list");
    grid.jqGrid({
        // define all jqGrid options
    });
    
    var originalCheckValues = $.jgrid.checkValues,
        originalHideModal = $.jgrid.hideModal,
        iColWithError = 0;
    $.jgrid.checkValues = function(val, valref,g, customobject, nam) {
        var tr,td,
            ret = originalCheckValues.call(this,val, valref,g, customobject, nam);
        if (!ret[0]) {
            tr = g.rows.namedItem(editingRowId);
            if (tr) {
                $(tr).children('td').children('input.editable[type="text"]').removeClass("ui-state-error");
                iColWithError = valref; // save to set later the focus
                //error_td_input_selector = 'tr#'+editingRowId+' > td:nth-child('+(valref+1)+') > input.editable[type="text"]:first';
                td = tr.cells[valref];
                if (td) {
                    $(td).find('input.editable[type="text"]').addClass("ui-state-error");
                }
            }
        }
        return ret;
    };
    $.jgrid.hideModal = function (selector,o) {
        var input, oldOnClose, td,
            tr = grid[0].rows.namedItem(editingRowId);
        if (tr) {
            td = tr.cells[iColWithError];
            if (td) {
                input = $(td).children('input.editable[type="text"]:first');
                if (input.length > 0) {
                    oldOnClose = o.onClose;
                    o.onClose = function(s) {
                        if ($.isFunction(oldOnClose)) {
                            oldOnClose.call(s);
                        }
                        setTimeout(function(){
                            input.focus();
                        },100);
                    };
                }
            }
        }
        originalHideModal.call(this,selector,o);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m using jqgrid with mvc 3, I want to add Edit and Delete
I am using jqGrid and I don't want the grid to autoload. I only
I am using jqgrid throughout my application. On two screens with inline edit, everything
I'm using jqgrid with inline editing , when the user gets to the last
We are using the jQuery('#grid').editRow() feature of jqGrid, that allows you to edit fields
Inline editing is started using edit formatter action button. If clicked in other row,
I am using a jqgrid where I'd like to use inline editing and mask
I'm using jqGrid plugin and I want to add onKeyPress event to each field
I am using jQgrid for doing a table and I want to add an
jQgrid row is edited using inline editing mode. Pressing Enter sends data to server

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.