diff --git a/examples/advanced_init/column_render.html b/examples/advanced_init/column_render.html index 3bcafbc7..6ac450e6 100644 --- a/examples/advanced_init/column_render.html +++ b/examples/advanced_init/column_render.html @@ -16,8 +16,11 @@ $('#example').dataTable( { "aoColumnDefs": [ { - "fnRender": function ( oObj, sVal ) { - return sVal +' '+ oObj.aData[3]; + // `data` refers to the data for the cell (defined by `mData`, which + // defaults to the column being worked with, in this case is the first + // Using `row[0]` is equivalent. + "mRender": function ( data, type, row ) { + return data +' '+ row[3]; }, "aTargets": [ 0 ] }, @@ -35,7 +38,8 @@
You may specify a function for each column to render the available data in a specific manner which will be called when the table is drawn. In this example I've appended the rendering engine version to the rendering engine name in the first column, and hidden the version column.
+Each column has an optional rendering control called mRender which can be used to process the content of each cell before the data is used. mRender
has a wide array of options available to it for rendering different types of data (sorting, filtering, display etc), but it can be used very simply to manipulate the content of a cell, as shown here.
This example shows the rendering engine version combined with the rendering engine name in the first column, hiding the version column. This technique can be useful for adding links, assigning colours based on content rules and any other form of text manipulation you require.
The following example shows how a callback function can be used to format a particular row at draw time. For each row that is generated for display, the fnRowCallback() function is called. It is passed the row node which can then be modified. In this case a trivial example of making the 'grade' column bold if the grade is 'A' is shown (note that this could also be performed using the fnRender() function, but this is just for example).
+The following example shows how a callback function can be used to format a particular row at draw time. For each row that is generated for display, the fnRowCallback() function is called. It is passed the row node which can then be modified. In this case a trivial example of making the 'grade' column bold if the grade is 'A' is shown (note that this could also be performed using mData as a function, but this is just for example of fnRowCallback!).