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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:43:58+00:00 2026-05-14T23:43:58+00:00

For one of the columns in my jqGrid, I’m providing a custom formatter function.

  • 0

For one of the columns in my jqGrid, I’m providing a custom formatter function. I’m providing some special cases, but if those conditions aren’t met, I’d like to resort to using the built-in date formatter utility method. It doesn’t seem that I’m getting the right combination of $.extend() to create the options that method is expecting.

My colModel for this column:

{ name:'expires', 
    index:'7',
    width:90,
    align:"right",
    resizable: false,
    formatter: expireFormat,
    formatoptions: {srcformat:"l, F d, Y g:i:s A",newformat:"n/j/Y"}
},

And an example of what I’m trying to do

function expireFormat(cellValue, opts, rowObject) {
    if (cellValue == null || cellValue == 1451520000) {
        // a specific date that should show as blank
        return '';
    } else {
        // here is where I'd like to just call the $.fmatter.util.DateFormat
        var dt = new Date(cellValue * 1000);
        var op = $.extend({},opts.date);
        if(!isUndefined(opts.colModel.formatoptions)) {
            op = $.extend({},op,opts.colModel.formatoptions);
        }
        return $.fmatter.util.DateFormat(op.srcformat,dt,op.newformat,op);
    }
}

(An exception is being thrown in the guts of that DateFormat method, looks like where it’s trying to read into a masks property of the options that get passed in)

EDIT:

The $.extend that put everything in the place it needed was getting it from that global property where the i18n library set it, $.jgrid.formatter.date.

var op = $.extend({}, $.jgrid.formatter.date);
if(!isUndefined(opts.colModel.formatoptions)) {
    op = $.extend({}, op, opts.colModel.formatoptions);
}
return $.fmatter.util.DateFormat(op.srcformat,dt.toLocaleString(),op.newformat,op);
  • 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-14T23:43:59+00:00Added an answer on May 14, 2026 at 11:43 pm

    In the jqGrid source code, different options are passed to the formatter when it is a built-in function versus when a custom formatter is used:

        formatter = function (rowId, cellval , colpos, rwdat, _act){
            var cm = ts.p.colModel[colpos],v;
            if(typeof cm.formatter !== 'undefined') {
                var opts= {rowId: rowId, colModel:cm, gid:ts.p.id };
                if($.isFunction( cm.formatter ) ) {
                    v = cm.formatter.call(ts,cellval,opts,rwdat,_act);
                } else if($.fmatter){
                    v = $.fn.fmatter(cm.formatter, cellval,opts, rwdat, _act);
                } else {
                    v = cellVal(cellval);
                }
            } else {
                v = cellVal(cellval);
            }
            return v;
        },
    

    So basically what’s going on is that when a built-in formatter is used, cm.formatter is passed as an argument. I need to confirm this, but based upon the error you are receiving, this appears to be a copy of the formatter options from grid.locale-en.js (or whatever version of the i18n file you are using). So when called internally the formatter would contain additional options such as masks – which is the one your code is failing on.

    As a preventative measure, I would try adding masks to your op variable. If that solves your problem then great, otherwise keep adding other missing options back into your code until it works.

    Does that help?

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

Sidebar

Related Questions

I have a script that appends some rows to a table. One of the
I've found several jQuery syntaxes for nullifying the enter on a form. First one:
I need to develop a file indexing application in python and wanted to know
My question is about memory use and objects in actionscript 2. If I have
I'm working on a project in C# w/ XNA, and I want to reorganize
I have a new web app that is packaged as a WAR as part
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
We manage a site for a medical charity. They have a number of links
Every time that I want to do a Layout, I'm getting a black layout
I want to use a temp directory that will be unique to this build.

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.