格式化程序上的JqGrid问题

格式化程序上的JqGrid问题,jqgrid,Jqgrid,我正在使用这个jqgrid: $("#griglia-navgrid").jqGrid( { colNames:[...], colModel:[ {name:'ZMENG_SOR_VRKME_PREC', index:'ZMENG_SOR_VRKME_PREC', width:'5', sortable:false, formatter:numFormat}, ], ... footerrow:tr

我正在使用这个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(".",",");
    }
$(“#格里利亚导航网格”).jqGrid({
colNames:[…],
colModel:[{name:'zming_SOR_VRKME_PREC',index:'zming_SOR_VRKME_PREC',width:'5',可排序:false,格式化程序:numFormat},],
...
是的,
afterInsertRow:function(id){$(“#griglia navgrid”).jqGrid('setCell',id,'ZPARVW_Z1','','',{'text-decoration':'underline'}),
loadComplete:函数(){
变量$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.myfooterow”);
如果($newFooterRow.length==0){
$newFooterRow=$footerRow.clone();
$newFooterRow.removeClass(“footrow”).addClass(“myfootrow ui小部件内容”);
$newFooterRow.children(“td”)。每个(函数(){
this.style.width=”“;//从内联CSS中删除宽度
});
$newFooterRow.insertAfter($footerRow);
}
对于(i=0;itd[aria descripbedby=“+this.id+”)”\u ZPARVW\u Z1\u NAME]”);
$newFooterRow.find(“>td[aria descripbedby=“+this.id+”)”\u ZMENG\u SOR\u VRKME]”。文本(
$.fmatter.util.NumberFormat(总和,$.jgrid.formatter.number.decimalSeparator=',')
);
}
}); //jqGrid
函数numFormat(单元格值、选项、行对象){
返回cellvalue。替换(“.”、“,”);
}
它适用于Safari和Chrome。在firefox中,我有一个错误:“ReferenceError:numFormat未定义”


如何解决此问题?

格式化程序函数应放在JQGrid定义之前。
然后它就可以工作了。

您能显示其余的代码吗?其中调用了$(“#grid”).jqGrid(),它是否在函数本身内部?
“ReferenceError:未定义”
是在未找到预期对象引用时发现的常规错误。请尝试在jqgrid定义之前定义函数“numFormat”。如果这不起作用,请更新有问题的jQGrid的整个代码,其中可能也有遗漏。Tks Pranav,我在jQGrid前面放了函数“numFormat”。。非常喜欢:D