Jqgrid 数据格式化配置

默认格式化

    $jgrid = {
            formatter : {  
              integer : {thousandsSeparator: " ", defaultValue: '0'},  
              number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},  
              currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},  
              date : {  
                dayNames: [  
                  "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",  
                  "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"  
                ],  
                monthNames: [  
                  "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",  
                  "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"  
                ],  
                AmPm : ["am","pm","AM","PM"],  
                S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},  
                srcformat: 'Y-m-d',  
                newformat: 'd/m/Y',  
                masks : {  
                  ISO8601Long:"Y-m-d H:i:s",  
                  ISO8601Short:"Y-m-d",  
                  ShortDate: "n/j/Y",  
                  LongDate: "l, F d, Y",  
                  FullDateTime: "l, F d, Y g:i:s A",  
                  MonthDay: "F d",  
                  ShortTime: "g:i A",  
                  LongTime: "g:i:s A",  
                  SortableDateTime: "Y-m-d\\TH:i:s",  
                  UniversalSortableDateTime: "Y-m-d H:i:sO",  
                  YearMonth: "F, Y"  
                },  
                reformatAfterEdit : false  
              },  
              baseLinkUrl: '',  
              showAction: '',  
              target: '',  
              checkbox : {disabled:true},  
              idName : 'id'  
            }
    };

自定义格式化

colModel: [
    {name:'id', index:'id', width:60, align:"center"},
    {name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter}
]

function currencyFmatter (cellvalue, options, rowObject){ 
    return new_format_value;
}

 

posted on 2015-05-22 14:00  510blog  阅读(1275)  评论(0)    收藏  举报