1

我有一个带有数字列的网格。我使用文件 grid.locale-it.js 并且网格中的数字显示正确(千位分隔符:. 和小数分隔符:, . 在编辑表单中,数字以标准美国表示 我应该怎么做才能格式化数字它也在编辑表格中吗?谢谢

这是页面源代码:

$("#grid").jqGrid({
        url: 'AnagArticoli.aspx',
        loadError : function(xhr, st, str){alert('Serverside load error!'); window.location.assign("elmah.axd");},
        editurl: 'AnagArticoli.aspx', 
        datatype: 'local',
        postData: { ActionPage: 'TransportType', Action: 'Fill' },
        multiselect: true,
    colNames: ['Codice articolo', 'Descrizione articolo', '','Area', '', 'key' ,],
    colModel: [
        { name: 'CodiceArticolo' 
         ,index: 'CodiceArticolo' 
         ,width: 100 
         ,align: 'Left' 
         ,editable: true 
        },
        { name: 'DescrizioneArticolo' 
         ,index: 'DescrizioneArticolo' 
        ,width: 350 
      ,align: 'Left' 
      ,editable: true 
        },
        { name: 'Peso' 
         ,index: 'Peso' 
      ,width: 80 
      ,align: 'Right' 
      ,sorttype: 'float' 
      ,editable: true 
      ,editoptions: { number: true}  
      ,editrules: { required:true, number:true } 
      ,formatter: 'number' 
        },
        { name: 'Area' 
         ,index: 'Area' 
      ,width: 80 
      ,align: 'Left' 
      ,editable: true 
      ,edittype: 'select' 
      ,editoptions: {value:'02:MANUALE;01:DEFAULT'} 
        },
        { name: 'DataUpdate' 
         ,index: 'DataUpdate' 
      ,width: 150 
      ,align: 'Left' 
      ,sorttype: 'float' 
      ,editable: true 
      ,editoptions: { size: 10, maxlengh: 10, dataInit: function(element) { $(element).datepicker({dateFormat: 'dd/mm/yy'}) } } 
      ,formatter: 'date' 
      , formatoptions:{ srcformat:'d/m/Y h:i:s', newformat:'d/m/Y h:i:s' } 
        },
        { name: 'key'
         , key: false, hidden: true, editable: true, editrules: { edithidden: false }, hidedlg: true 
        },
    ],
    ignoreCase:true,
    cellEdit: false,
    onSelectRow: function(id) {
        if (id && id !== lastSel) {
            grid.jqGrid('restoreRow',lastSel);
        }
    },
    height: 'auto',
    rowNum: 10,
    rowList: [10, 20, 30],
    pager: '#pager',
    sortname: 'CodiceArticolo',
    viewrecords: true,
    sortorder: 'desc',
    mtype: 'GET',
    sortable: true,
    loadonce: true,
    gridComplete: function(){ 
        $("#grid").setGridParam({datatype: 'local'}); 
        grid.jqGrid('hideCol', 'cb'); 
    },
    beforeSelectRow: function (rowid, e) {
        if (!e.ctrlKey && !e.shiftKey) {
            $("#grid").jqGrid('resetSelection');
            LastSelectIndex = $("#grid").jqGrid('getInd', rowid);
        }
        else if (e.shiftKey) {
            var initialRowSelect = $("#grid").jqGrid('getGridParam', 'selrow');
            $("#grid").jqGrid('resetSelection');
            var CurrentSelectIndex = $("#grid").jqGrid('getInd', rowid);
            var InitialSelectIndex = $("#grid").jqGrid('getInd', initialRowSelect);
            var startID = "";
            var endID = "";
            if (CurrentSelectIndex > InitialSelectIndex) {
                startID = initialRowSelect;
                endID = rowid;
            }
            else {
                startID = rowid;
                endID = initialRowSelect;
            }
            var shouldSelectRow = false;
            $.each($("#grid").getDataIDs(), function(_, id){
               if ((shouldSelectRow = id == startID || shouldSelectRow) && (id != rowid)){
                  $("#grid").jqGrid('setSelection', id, false);
                }
                return id != endID;
            });
        }
        return true;
    }, 
});

$("#grid").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "cn"});
    $("#grid").jqGrid('navGrid', '#pager', 
           { 
               add:true, 
               del:true, 
               edit:true, 
               refresh:true, 
               search:true, 
           },
        { width: 500, modal: true, editData: { ActionPage: 'TransportType', Action: 'Update'}, savekey: [true, 13], recreateForm: true, closeOnEscape: true, closeAfterEdit: true, mtype: 'POST', reloadAfterSubmit: true, 
           afterSubmit: function () {
               $(this).jqGrid("setGridParam", {datatype: 'json'});
               return [true];
           }
        }, // EDIT OPTION
        { width: 500, modal: true, editData: { ActionPage: 'TransportType', Action: 'Insert' }, closeOnEscape: true, closeAfterAdd: true, }, // ADD OPTION
        { // del options 
          width: 500, modal: true, bSubmit: 'Elimina', caption: 'Cancellazione', reloadAfterSubmit: true, closeOnEscape: true, 
             beforeShowForm: function(form) {
                $('td.delmsg',form).html('Do you really want delete the row with <b>id=' +
                                    $("#grid").jqGrid('getGridParam','selarrrow') + '</b>?');
             } 
            }, 
        { width: 460, closeOnEscape: true, multipleSearch: true, recreateFilter: true, overlay: false } // SEARCH OPTION
    );
    $("#grid").jqGrid('inlineNav','#pager', {addParams: {addRowParams: {}}});
4

0 回答 0