Rendering plug-ins
Data renderers can be used to transform data from a feed from one format into another. This can be useful if you want to customise the data the user sees - for example showing an ISO8601 date from a feed as a localised data format.
DataTables has two built in renderers (number
and text
), which can be expanded upon through the plug-ins below. More can also be created as required - please see this blog post for a full description on creating your own plug-ins.
How to use
Rendering plug-ins are really just functions that are attached to the columns.render
option. See the DataTables renderers documentation for more details.
As an example the code below makes use of the ellipsis plug-in saved into a file:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.dataTables.js"></script>
<script type="text/javascript" src="dataTables.ellipsis.js"></script>
<script type="text/javascript">
$('#myTable').DataTable( {
columnDefs: [ {
targets: 0,
render: $.fn.dataTable.render.ellipsis()
} ]
} );
</script>
Plug-ins
datetime | Convert date / time source data into one suitable for display |
ellipsis | Restrict output data to a particular length, showing anything |
hyperLink | Displays url data in hyperLink with custom plcaeholder |
intl | Use the Intl Javascript API to render dates and numbers |
percentageBars | Display percentage value as a bar |