SCRIPT438:对象不支持属性或方法“formatCurrency'" [英] SCRIPT438: Object doesn't support property or method 'formatCurrency'"

查看:2864
本文介绍了SCRIPT438:对象不支持属性或方法“formatCurrency'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个:试图格式化货币使用jQuery formatCurrency库细胞在jQuery的数据表时,SCRIPT438对象不支持属性或方法formatCurrency'错误

I am getting an "SCRIPT438: Object doesn't support property or method 'formatCurrency'"" error when trying to format the currency for cells in a jQuery datatable using the jQuery formatCurrency library.

code:
jQuery的数据表初始化:

Code: jQuery DataTable initialisation:

var oTable = $('#tblTest').dataTable({
"bFilter": false,
"bInfo": false,
"aoColumns": [{ "bVisible": false }, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null],
"aaSorting": [[0, 'desc', 1]],
"bScrollInfinite": true, //this property disables pagination
"sScrollY": "230px",
"sScrollX": "940px",
"fnCreatedRow": function (nRow, aData, iDataIndex) {
 RefreshGrid();
  }
});

function RefreshGrid() {
        var nRow = $('#tblTest').dataTable().fnGetNodes();
        for (var i = 0; i < nRow.length; i++) {
            var Total = (nRow[i].children[6].children[0].innerHTML * nRow[i].children[7].children[0].innerHTML).toFixed(2);
            $("input[id$='hfFormat']").val(Total);
            var unformatted = $("input[id$='hfFormat']").val();
            var formatted = $("input[id$='hfFormat']").val(unformatted).formatCurrency().val();
            nRow[i].children[8].children[0].innerHTML = formatted; //Total;
            var Veriance = Total - nRow[i].children[11].children[0].value;
            nRow[i].children[13].children[0].innerHTML = Veriance.toFixed(2);


            nRow[i].children[9].children[0].disabled = true; //CrNo
            nRow[i].children[10].children[0].disabled = true; //Allocate
            nRow[i].children[11].children[0].disabled = true; //CrAmount
            nRow[i].children[14].children[0].disabled = true; //Accept Veriance
            nRow[i].children[15].children[0].disabled = true; //Edit

            nRow[i].children[10].children[0].checked = false; //Allocate
            nRow[i].children[14].children[0].checked = false; //Accept Veriance
            nRow[i].children[15].children[0].checked = false; //Edit
            nRow[i].style.backgroundColor = "";

            if (nRow[i].children[12].children[0].defaultValue == "RejectedReturn") {
                nRow[i].style.backgroundColor = "#FFEDE6";
            }
            else if (nRow[i].children[12].children[0].defaultValue == "CompleteWithVariance") {
                nRow[i].children[15].children[0].disabled = false; //Edit
                nRow[i].children[14].children[0].checked = true; //Accept Verianc
                nRow[i].style.backgroundColor = "#D1D1D1";
            }
            else if (nRow[i].children[12].children[0].defaultValue == "Complete") {
                nRow[i].children[15].children[0].disabled = false; //Edit
                nRow[i].children[10].children[0].checked = true; //Allocate
                nRow[i].style.backgroundColor = "#D1D1D1";
            }
            else if (nRow[i].children[12].children[0].defaultValue == "Outstanding") {
                nRow[i].children[9].children[0].disabled = false; //CrNo
                nRow[i].children[10].children[0].disabled = false; //Allocate
                nRow[i].children[11].children[0].disabled = false; //CrAmount
                nRow[i].children[14].children[0].disabled = false; //Accept Veriance
            }
            else if (nRow[i].children[12].children[0].defaultValue == "Partial") {
                nRow[i].children[9].children[0].disabled = false; //CrNo
                nRow[i].children[10].children[0].disabled = false; //Allocate
                nRow[i].children[11].children[0].disabled = false; //CrAmount
                nRow[i].children[14].children[0].disabled = false; //Accept Veriance

            }
        }
    }

同样的方法在其他网页的工作,但在这里,唯一的区别是,RefreshGrid()正在从fnCreatedRow函数调用而在其他情况下,它是从fnRowCallback和fnFooterCallback函数调用。
在格式化的价值将在隐藏字段present。

The same approach worked in other web pages but the only difference here is that RefreshGrid() is being called from the fnCreatedRow function whereas in the other instances it was called from the fnRowCallback and fnFooterCallback functions. The "unformatted" value will be present in the hidden field.

推荐答案

原来,问题是有重复的jQuery库脚本:页面和页面上的用户控件上。让我感动的脚本引用到母版页和子页面中删除,并控制,以避免重复。
感谢您的帮助家伙!

Turns out the problem was with duplicated jquery library scripts: on the page and a user control on the page. I moved the script reference to the Master page and removed from the Child pages and controls to avoid the duplication. Thanks for the assistance guys!

这篇关于SCRIPT438:对象不支持属性或方法“formatCurrency'&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆