0

我正在使用这个 jqgrid:

$("#griglia-navgrid").jqGrid( { 
        colNames:[...],               
        colModel:[ {name:'ZMENG_SOR_VRKME_PREC', index:'ZMENG_SOR_VRKME_PREC', width:'5', sortable:false, formatter:numFormat},  ],
        ...
       footerrow:true,
       afterInsertRow: function(id){    $("#griglia-navgrid").jqGrid('setCell',id,'ZPARVW_Z1','',{'text-decoration':'underline'}); },
               loadComplete: function () {
               var $this = $(this),
                sum = $this.jqGrid("getCol", "ZMENG_SOR_VRKME", false, "sum"),
                $footerRow = $(this.grid.sDiv).find("tr.footrow"),localData = $this.jqGrid("getGridParam", "data"),totalRows = localData.length,totalSum = 0,   $newFooterRow, i;
 $newFooterRow = $(this.grid.sDiv).find("tr.myfootrow");
            if ($newFooterRow.length === 0) {
                $newFooterRow = $footerRow.clone();
                $newFooterRow.removeClass("footrow").addClass("myfootrow ui-widget-content");
                $newFooterRow.children("td").each(function () {
                    this.style.width = ""; // remove width from inline CSS
                });
                $newFooterRow.insertAfter($footerRow);
            }
            for (i = 0; i < totalRows; i++) {
                if(localData[i].ZMENG_SOR_VRKME.search("-") == -1){
                     totalSum += parseFloat(localData[i].ZMENG_SOR_VRKME);}
                else{
                    totalSum -= parseFloat(localData[i].ZMENG_SOR_VRKME);
                    }
            }
            $newFooterRow.find(">td[aria-describedby=" + this.id + "_ZPARVW_Z1_NAME]").text("Totale:");
            $newFooterRow.find(">td[aria-describedby=" + this.id + "_ZMENG_SOR_VRKME]").text(
                $.fmatter.util.NumberFormat(totalSum, $.jgrid.formatter.number.decimalSeparator=',')
            );
        }
    }); //jqGrid

    function numFormat( cellvalue, options, rowObject ){
        return cellvalue.replace(".",",");
    }

它适用于 Safari 和 Chrome。在 Firefox 中我有一个错误:“ReferenceError:numFormat 未定义”。

我该如何解决这个问题?

4

1 回答 1

0

格式化程序函数应该放在 JQGrid 定义之前。然后它会工作。

于 2013-07-17T20:50:07.050 回答