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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:26:55+00:00 2026-05-22T12:26:55+00:00

I populate a new grid from json with custom formatter the formatter is defined

  • 0

I populate a new grid from json
with custom formatter
the formatter is defined :

testFormatter(value,el,opts)
{
     if (value==0)
     {
          $(el).addClass("Fail");
     }
     …
}

I am expecting the cells to use the css class
but If I check the cells they don’t add that class.

  • 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-22T12:26:56+00:00Added an answer on May 22, 2026 at 12:26 pm

    You made the typical error of the usage of the custom formatter. It is important to understand that the jqGrid has the best performance if the grid contain will be created as the string. In the case the gridview:true gives you the performance. Any custom formatter should work in the gridview:true mode, so the custom formater has no parameter which are DOM element and so you can not use operations like $(el).addClass("Fail");

    In some old answers (see here and here) you can find how the problem can be solved, but I would you suggest to use new feature of jqGrid 4.0.0: cellattr option. For undefrstanding: the purpose of the custom formatter is not add some HTML attributes like class for example. It should be used for example to convert some universal date format like yyyy-mm-dd to localized form like dd.mm.yyyy (German style). If you don’t want to change format of the column, but want only add some attributes like title (used for tooltips), class (like in your case), style and so on the new cellattr option is what you need.

    In you case you can define

    cellattr: function(rowId, cellValue, rawObject, cm, rdata) {
        if (cellValue==0) {
            return ' class="Fail"';
        }
    }
    

    See a small demo here:

    enter image description here

    In the demo I added calsses ui-state-error and ui-state-error-text to all cells of 'Client' column where in the 'Closed' the checkbox is set.

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

Sidebar

Related Questions

I populate the GridView.DataSource from a EntityFramework Model: gwTimeLog.DataSource = _entities.TimeLogs; When a new
I'm having problem loading data from JSON store to EXT grid. Following is the
I am new at this. I am trying to populate a datagrid from a
I populate a DataGrid from a CollectionViewSource. Each row has a delete button. On
I am trying to populate a string with a double value using a sprintf
I need to populate a context menu from a database at run time. I
After writing code to populate textboxes from an object, such as: txtFirstName.Text = customer.FirstName;
I have set up jqGrid with JSON in my .Net MVC project. The grid
i have a method that will populate a datatable with the data from a
I am new to jQuery, trying to populate a GridView or Telerik RadGrid using

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.