Adding A $ sign to column numbers

Adding A $ sign to column numbers

dobulet302dobulet302 Posts: 38Questions: 0Answers: 0
edited August 2010 in General
I am currently using the following code to add a comma to the targeted columns
[code]
"aoColumnDefs": [
{
"aTargets": [2,3,4,5 ],
"bUseRendered": false,
"fnRender": function ( o ) {
return o.oSettings.fnFormatNumber( parseFloat( o.aData[ o.iDataColumn ] ) );
}
}
]
[/code]

how can I add a dollar sign to column 1?

Replies

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Just concatenate it onto the string?:

    [code]
    "aoColumnDefs": [
    {
    "aTargets": [1],
    "fnRender": function ( o ) {
    return "$"+o.aData[ o.iDataColumn ];
    }
    },
    {
    "aTargets": [2,3,4,5 ],
    "bUseRendered": false,
    "fnRender": function ( o ) {
    return o.oSettings.fnFormatNumber( parseFloat( o.aData[ o.iDataColumn ] ) );
    }
    }
    ]
    [/code]
    Allan
  • wtjoneswtjones Posts: 2Questions: 0Answers: 0
    edited August 2011
    This is what I did to left-justify the dollar sign:

    [code]
    "aoColumnDefs":
    [
    {
    "aTargets": [5],
    "bUseRendered":false,
    "fnRender": function(o) {
    return ''
    + '$'
    + ''
    + o.aData[o.iDataColumn]
    + "";
    }
    }
    ]
    [/code]
This discussion has been closed.