Note that there are some explanatory texts on larger screens.

plurals
  1. POSCRIPT438: Object doesn't support property or method 'formatCurrency'"
    primarykey
    data
    text
    <p>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. </p> <p>Code: jQuery DataTable initialisation:</p> <pre><code>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 &lt; 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 } } } </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload