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