當我嘗試格式化單元格的貨幣在jQuery數據表中時,出現」SCRIPT438:對象不支持屬性或方法「formatCurrency'」「錯誤使用jQuery formatCurrency庫。SCRIPT438:對象不支持屬性或方法'formatCurrency'「
代碼: jQuery的數據表初始化:
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函數中調用。 「未格式化」值將出現在隱藏字段中。
感謝您的拼寫糾正,我嘗試了您的建議,沒有改變。這可能是你提到的鏈接。 – user2248185 2013-04-11 15:56:49
然後我得到一個「SCRIPT438:對象不支持屬性或方法」toNumber'「錯誤。我會說選擇器無法找到隱藏的字段對象,但是當我使用它來獲取隱藏字段的值時,它將返回值。 – user2248185 2013-04-12 07:34:52
我給你的下一個建議是逐行檢查頁面上運行的所有JS的語法。 SCRIPT438錯誤通常是由腳本中其他位置的無效語法錯誤引起的。 – 2013-04-12 15:32:15