Pablo
Pablo

Reputation: 167

jqGrid: format options being ignored

My format options are being ignored:

{name:'effectiveDate', 
        width:'80',  
        align: 'center',
        editable:true, 
        formatter: 'date',
        srcformat:'ISO8601Short',
        newformat: 'Y-m-d', 
        edittype:'date', 
        editrules:{
        required:true
               }
}

The backend sends json dates in mm-dd-yyyy format. They are correctly parsed by jqGrid, the values are correct and displayed in the grid with m/d/y format, but I cannot change the formatting, no matter what I input for 'newformat', even if I input garbage it will just ignore it and always display m/d/y. Could it be that I'm missing the Formatter module, or is there another explanation? How can I verify if I have the Formatter module?

Upvotes: 0

Views: 1831

Answers (1)

Oleg
Oleg

Reputation: 221997

The properties srcformat and newformat are the options of formatter. So you should follow the documentation and rewrite the column definition to

{
    name:'effectiveDate', 
    width: 80,  
    align: 'center',
    editable: true, 
    formatter: 'date',
    formatoptions: {
        srcformat:'ISO8601Short',
        newformat: 'Y-m-d', 
    },
    editrules: {
        required:true
    }
}

By the way jqGrid don't know edittype: 'date'. See the documentation. The format mm-dd-yyyy is not ISO8601 date format. Correct ISO8601 format is yyyy-mm-dd. I hope the sever use the format in the JSON response.

Upvotes: 1

Related Questions