Displaying Characters Such As The Percent Sign
Displaying Characters Such As The Percent Sign
I am trying to get the percentage sign behind an INT field value column. I've searched but almost all forum posts relate to the Legacy Interface notice for earlier versions.
The only place I've found in either the manual or forum post similar was a forum post and applied the following code, but it leaves the % sign in front of the integer:
{ data: "Pct_Dif_Price", render: $.fn.dataTable.render.number('', '', 'post', '%', 0 ), "sClass": "alignright" },
How can I display characters before or after what is in the cell?
Thanks
Answers
You would need to use
columns.render
to format and display the number as you wish. Thenumber
rendering helper doesn't currently have an option to add a postfix character.Allan
It worked in-part.
When I target two columns, 49 and 50, only the 49th column displays the %. I thought maybe a comma after the 50 but still no display of the % sign in column 50.
Allan,
Figured it out. I had the number rendering helper already in the "data:" column 50 and removed it.
This actually now raises a very interesting question, are functions such as render superceded like CSS, meaning external, then in-page (header), then inline?
Example: Would render inline with "Data:" supercede render in columnDef?
I don't understand what you mean by
render inline
. As in using thecolumns
option? Yes,columns will always take priority over the options defined in
columnDefs`.Allan
Should just update the number render function with,
Yes I plan to. Thanks for the suggestion.
Allan