1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-29 11:24:10 +01:00
DataTables/examples/advanced_init/column_render.html
Allan Jardine 4e5cad9640 Size: The default formatNumber method has been reduced in size.
- Exactly the same functionality, but now uses a regex to perform the
  same operation
2013-09-23 11:44:58 +01:00

650 lines
19 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
<title>DataTables example - Column rendering</title>
<link rel="stylesheet" type="text/css" href="../../media/css/jquery.dataTables.css">
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#example').dataTable( {
"columnDefs": [
{
// The `data` parameter refers to the data for the cell (defined by the
// `data` option, which defaults to the column being worked with, in
// this case `data: 0`.
"render": function ( data, type, row ) {
return data +' '+ row[3];
},
"targets": 0
},
{ "visible": false, "targets": [ 3 ] }
]
} );
} );
</script>
</head>
<body class="dt-example">
<div class="container">
<h1>DataTables example - Column rendering</h1>
<p>Each column has an optional rendering control called <a href=
"//datatables.net/init/columns.render"><code>columns.render</code></a> which can be used to process the content
of each cell before the data is used. <a href=
"//datatables.net/init/columns.render"><code>columns.render</code></a> has a wide array of options available to
it for rendering different types of data orthogonally (sorting, filtering, display etc), but it can be used
very simply to manipulate the content of a cell, as shown here.</p>
<p>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.</p>
<section>
<table id="example" class="display" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>61</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>63</td>
<td>Director</td>
<td>Edinburgh</td>
<td>2011/07/25</td>
<td>$5,300</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>66</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>2009/01/12</td>
<td>$4,800</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>22</td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>2012/03/29</td>
<td>$3,600</td>
</tr>
<tr>
<td>Jenna Elliott</td>
<td>33</td>
<td>Financial Controller</td>
<td>Edinburgh</td>
<td>2008/11/28</td>
<td>$5,300</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>61</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>2012/12/02</td>
<td>$4,525</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>59</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>2012/08/06</td>
<td>$4,080</td>
</tr>
<tr>
<td>Rhona Davidson</td>
<td>55</td>
<td>Integration Specialist</td>
<td>Edinburgh</td>
<td>2010/10/14</td>
<td>$6,730</td>
</tr>
<tr>
<td>Colleen Hurst</td>
<td>39</td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>2009/09/15</td>
<td>$5,000</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>23</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>2008/12/13</td>
<td>$3,600</td>
</tr>
<tr>
<td>Jena Gaines</td>
<td>30</td>
<td>System Architect</td>
<td>London</td>
<td>2008/12/19</td>
<td>$5,000</td>
</tr>
<tr>
<td>Quinn Flynn</td>
<td>22</td>
<td>Financial Controller</td>
<td>Edinburgh</td>
<td>2013/03/03</td>
<td>$4,200</td>
</tr>
<tr>
<td>Charde Marshall</td>
<td>36</td>
<td>Regional Director</td>
<td>San Francisco</td>
<td>2008/10/16</td>
<td>$5,300</td>
</tr>
<tr>
<td>Haley Kennedy</td>
<td>43</td>
<td>Senior Marketing Designer</td>
<td>London</td>
<td>2012/12/18</td>
<td>$4,800</td>
</tr>
<tr>
<td>Tatyana Fitzpatrick</td>
<td>19</td>
<td>Regional Director</td>
<td>London</td>
<td>2010/03/17</td>
<td>$2,875</td>
</tr>
<tr>
<td>Michael Silva</td>
<td>66</td>
<td>Senior Marketing Designer</td>
<td>London</td>
<td>2012/11/27</td>
<td>$3,750</td>
</tr>
<tr>
<td>Paul Byrd</td>
<td>64</td>
<td>Javascript Developer</td>
<td>New York</td>
<td>2010/06/09</td>
<td>$5,000</td>
</tr>
<tr>
<td>Gloria Little</td>
<td>59</td>
<td>Systems Administrator</td>
<td>New York</td>
<td>2009/04/10</td>
<td>$3,120</td>
</tr>
<tr>
<td>Bradley Greer</td>
<td>41</td>
<td>Software Engineer</td>
<td>London</td>
<td>2012/10/13</td>
<td>$3,120</td>
</tr>
<tr>
<td>Dai Rios</td>
<td>35</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>2012/09/26</td>
<td>$4,200</td>
</tr>
<tr>
<td>Jenette Caldwell</td>
<td>30</td>
<td>Financial Controller</td>
<td>New York</td>
<td>2011/09/03</td>
<td>$4,965</td>
</tr>
<tr>
<td>Yuri Berry</td>
<td>40</td>
<td>System Architect</td>
<td>New York</td>
<td>2009/06/25</td>
<td>$3,600</td>
</tr>
<tr>
<td>Caesar Vance</td>
<td>21</td>
<td>Technical Author</td>
<td>New York</td>
<td>2011/12/12</td>
<td>$4,965</td>
</tr>
<tr>
<td>Doris Wilder</td>
<td>23</td>
<td>Sales Assistant</td>
<td>Edinburgh</td>
<td>2010/09/20</td>
<td>$4,965</td>
</tr>
<tr>
<td>Angelica Ramos</td>
<td>36</td>
<td>System Architect</td>
<td>London</td>
<td>2009/10/09</td>
<td>$2,875</td>
</tr>
<tr>
<td>Gavin Joyce</td>
<td>42</td>
<td>Developer</td>
<td>Edinburgh</td>
<td>2010/12/22</td>
<td>$4,525</td>
</tr>
<tr>
<td>Jennifer Chang</td>
<td>28</td>
<td>Regional Director</td>
<td>London</td>
<td>2010/11/14</td>
<td>$4,080</td>
</tr>
<tr>
<td>Brenden Wagner</td>
<td>18</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>2011/06/07</td>
<td>$3,750</td>
</tr>
<tr>
<td>Ebony Grimes</td>
<td>48</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>2010/03/11</td>
<td>$2,875</td>
</tr>
<tr>
<td>Russell Chavez</td>
<td>20</td>
<td>Director</td>
<td>Edinburgh</td>
<td>2011/08/14</td>
<td>$3,600</td>
</tr>
<tr>
<td>Michelle House</td>
<td>37</td>
<td>Integration Specialist</td>
<td>Edinburgh</td>
<td>2011/06/02</td>
<td>$3,750</td>
</tr>
<tr>
<td>Suki Burks</td>
<td>53</td>
<td>Developer</td>
<td>London</td>
<td>2009/10/22</td>
<td>$2,875</td>
</tr>
<tr>
<td>Prescott Bartlett</td>
<td>27</td>
<td>Technical Author</td>
<td>London</td>
<td>2011/05/07</td>
<td>$6,730</td>
</tr>
<tr>
<td>Gavin Cortez</td>
<td>22</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>2008/10/26</td>
<td>$6,730</td>
</tr>
<tr>
<td>Martena Mccray</td>
<td>46</td>
<td>Integration Specialist</td>
<td>Edinburgh</td>
<td>2011/03/09</td>
<td>$4,080</td>
</tr>
<tr>
<td>Unity Butler</td>
<td>47</td>
<td>Senior Marketing Designer</td>
<td>San Francisco</td>
<td>2009/12/09</td>
<td>$3,750</td>
</tr>
<tr>
<td>Howard Hatfield</td>
<td>51</td>
<td>Financial Controller</td>
<td>San Francisco</td>
<td>2008/12/16</td>
<td>$4,080</td>
</tr>
<tr>
<td>Hope Fuentes</td>
<td>41</td>
<td>Financial Controller</td>
<td>San Francisco</td>
<td>2010/02/12</td>
<td>$4,200</td>
</tr>
<tr>
<td>Vivian Harrell</td>
<td>62</td>
<td>System Architect</td>
<td>San Francisco</td>
<td>2009/02/14</td>
<td>$4,965</td>
</tr>
<tr>
<td>Timothy Mooney</td>
<td>37</td>
<td>Financial Controller</td>
<td>London</td>
<td>2008/12/11</td>
<td>$4,200</td>
</tr>
<tr>
<td>Jackson Bradshaw</td>
<td>65</td>
<td>Director</td>
<td>New York</td>
<td>2008/09/26</td>
<td>$5,000</td>
</tr>
<tr>
<td>Miriam Weiss</td>
<td>64</td>
<td>Support Engineer</td>
<td>Edinburgh</td>
<td>2011/02/03</td>
<td>$4,965</td>
</tr>
<tr>
<td>Bruno Nash</td>
<td>38</td>
<td>Software Engineer</td>
<td>London</td>
<td>2011/05/03</td>
<td>$4,200</td>
</tr>
<tr>
<td>Odessa Jackson</td>
<td>37</td>
<td>Support Engineer</td>
<td>Edinburgh</td>
<td>2009/08/19</td>
<td>$3,600</td>
</tr>
<tr>
<td>Thor Walton</td>
<td>61</td>
<td>Developer</td>
<td>New York</td>
<td>2013/08/11</td>
<td>$3,600</td>
</tr>
<tr>
<td>Finn Camacho</td>
<td>47</td>
<td>Support Engineer</td>
<td>San Francisco</td>
<td>2009/07/07</td>
<td>$4,800</td>
</tr>
<tr>
<td>Elton Baldwin</td>
<td>64</td>
<td>Data Coordinator</td>
<td>Edinburgh</td>
<td>2012/04/09</td>
<td>$6,730</td>
</tr>
<tr>
<td>Zenaida Frank</td>
<td>63</td>
<td>Software Engineer</td>
<td>New York</td>
<td>2010/01/04</td>
<td>$4,800</td>
</tr>
<tr>
<td>Zorita Serrano</td>
<td>56</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>2012/06/01</td>
<td>$5,300</td>
</tr>
<tr>
<td>Jennifer Acosta</td>
<td>43</td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>2013/02/01</td>
<td>$2,875</td>
</tr>
<tr>
<td>Cara Stevens</td>
<td>46</td>
<td>Sales Assistant</td>
<td>New York</td>
<td>2011/12/06</td>
<td>$4,800</td>
</tr>
<tr>
<td>Hermione Butler</td>
<td>47</td>
<td>Director</td>
<td>London</td>
<td>2011/03/21</td>
<td>$4,080</td>
</tr>
<tr>
<td>Lael Greer</td>
<td>21</td>
<td>Systems Administrator</td>
<td>London</td>
<td>2009/02/27</td>
<td>$3,120</td>
</tr>
<tr>
<td>Jonas Alexander</td>
<td>30</td>
<td>Developer</td>
<td>San Francisco</td>
<td>2010/07/14</td>
<td>$5,300</td>
</tr>
<tr>
<td>Shad Decker</td>
<td>51</td>
<td>Regional Director</td>
<td>Edinburgh</td>
<td>2008/11/13</td>
<td>$5,300</td>
</tr>
<tr>
<td>Michael Bruce</td>
<td>29</td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>2011/06/27</td>
<td>$4,080</td>
</tr>
<tr>
<td>Donna Snider</td>
<td>27</td>
<td>System Architect</td>
<td>New York</td>
<td>2011/01/25</td>
<td>$3,120</td>
</tr>
</tbody>
</table>
</section>
<section>
<h3><a href="../basic_init/index.html">Basic Init</a></h3>
<ul class="toc">
<li><a href="../basic_init/complex_header.html">Complex headers (rowspan and colspan)</a></li>
<li><a href="../basic_init/dom.html">DOM positioning</a></li>
<li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
<li><a href="../basic_init/filter_only.html">Feature enable / disable</a></li>
<li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
<li><a href="../basic_init/alt_pagination.html">Alternative pagination</a></li>
<li><a href="../basic_init/language.html">Language options</a></li>
<li><a href="../basic_init/multi_col_sort.html">Multi-column sorting</a></li>
<li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
<li><a href="../basic_init/scroll_y_theme.html">Scroll - vertical with jQuery UI ThemeRoller</a></li>
<li><a href="../basic_init/scroll_x.html">Scroll - horizontal</a></li>
<li><a href="../basic_init/scroll_xy.html">Scroll - horizontal and vertical</a></li>
<li><a href="../basic_init/state_save.html">State saving</a></li>
<li><a href="../basic_init/zero_configuration.html">Zero configuration</a></li>
<li><a href="../basic_init/table_sorting.html">Default sorting</a></li>
<li><a href="../basic_init/themes.html">jQuery UI themes</a></li>
<li><a href="../basic_init/scroll_y.html">Scroll - vertical</a></li>
</ul>
<h3><a href="./index.html">Advanced Init</a></h3>
<ul class="toc active">
<li><a href="./complex_header.html">Complex headers (rowspan / colspan)</a></li>
<li><a href="./defaults.html">Defaults</a></li>
<li><a href="./dom_multiple_elements.html">Multiple table control elements</a></li>
<li><a href="./dom_toolbar.html">Custom toolbar elements</a></li>
<li class="active"><a href="./column_render.html">Column rendering</a></li>
<li><a href="./dt_events.html">DataTables events</a></li>
<li><a href="./events_live.html">Events</a></li>
<li><a href="./footer_callback.html">Footer callback</a></li>
<li><a href="./length_menu.html">Page length options</a></li>
<li><a href="./row_callback.html">Row created callback</a></li>
<li><a href="./sort_direction_control.html">Row grouping</a></li>
<li><a href="./row_grouping.html">Row grouping</a></li>
<li><a href="./language_file.html">Language file</a></li>
</ul>
<h3><a href="../styling/index.html">Styling</a></h3>
<ul class="toc">
<li><a href="../styling/display.html">Base style</a></li>
<li><a href="../styling/no-classes.html">Base style - no styling classes</a></li>
<li><a href="../styling/row-border.html">Base style - row borders</a></li>
<li><a href="../styling/cell-border.html">Base style - cell borders</a></li>
<li><a href="../styling/hover.html">Base style - hover</a></li>
<li><a href="../styling/sort-column.html">Base style - sort-column</a></li>
<li><a href="../styling/stripe.html">Base style - stripe</a></li>
<li><a href="../styling/jqueryUI.html">jQuery UI ThemeRoller</a></li>
<li><a href="../styling/bootstrap.html">Bootstrap</a></li>
<li><a href="../styling/foundation.html">Foundation</a></li>
</ul>
<h3><a href="../data_sources/index.html">Data Sources</a></h3>
<ul class="toc">
<li><a href="../data_sources/dom.html">DOM sourced data</a></li>
<li><a href="../data_sources/ajax.html">Ajax sourced data</a></li>
<li><a href="../data_sources/js_array.html">Javascript sourced data</a></li>
<li><a href="../data_sources/server_side.html">Server-side processing</a></li>
</ul>
<h3><a href="../ajax/index.html">Ajax</a></h3>
<ul class="toc">
<li><a href="../ajax/simple.html">Ajax data source (arrays)</a></li>
<li><a href="../ajax/objects.html">Ajax data source (objects)</a></li>
<li><a href="../ajax/deep.html">Nested object data (objects)</a></li>
<li><a href="../ajax/objects_subarrays.html">Nested object data (arrays)</a></li>
<li><a href="../ajax/null_data_source.html">Generated content for a column</a></li>
<li><a href="../ajax/custom_data_property.html">AJAX custom data source example</a></li>
<li><a href="../ajax/defer_render.html">AJAX deferred rendering example</a></li>
</ul>
<h3><a href="../server_side/index.html">Server Side</a></h3>
<ul class="toc">
<li><a href="../server_side/simple.html">Server-side processing</a></li>
<li><a href="../server_side/custom_vars.html">Custom HTTP variables</a></li>
<li><a href="../server_side/post.html">POST data</a></li>
<li><a href="../server_side/ids.html">Automatic addition of row ID attributes</a></li>
<li><a href="../server_side/object_data.html">Object data source</a></li>
<li><a href="../server_side/row_details.html">POST data</a></li>
<li><a href="../server_side/select_rows.html">Row selection</a></li>
<li><a href="../server_side/jsonp.html">JSONP data source for remote domains</a></li>
<li><a href="../server_side/defer_loading.html">Deferred loading of data</a></li>
<li><a href="../server_side/pipeline.html">Pipelining data to reduce Ajax calls for paging</a></li>
</ul>
<h3><a href="../api/index.html">Api</a></h3>
<ul class="toc">
<li><a href="../api/api_in_init.html">Using API in callbacks</a></li>
<li><a href="../api/counter_columns.html">Index column</a></li>
<li><a href="../api/form.html">Form inputs</a></li>
<li><a href="../api/highlight.html">Highlighting rows and columns</a></li>
<li><a href="../api/add_row.html">Add rows</a></li>
<li><a href="../api/multi_filter.html">Individual column filtering (text inputs)</a></li>
<li><a href="../api/multi_filter_select.html">Individual column filtering (select inputs)</a></li>
<li><a href="../api/select_row.html">Row selection (multiple rows)</a></li>
<li><a href="../api/regex.html">Filtering API (regular expressions)</a></li>
<li><a href="../api/select_single_row.html">Row selection and deletion (single row)</a></li>
<li><a href="../api/tabs_and_scrolling.html">Scrolling and jQuery UI tabs</a></li>
<li><a href="../api/show_hide.html">Show / hide columns dynamically</a></li>
<li><a href="../api/row_details.html">Child rows (show extra / detailed information)</a></li>
</ul>
<h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
<ul class="toc">
<li><a href="../plug-ins/api.html">API plug-in methods</a></li>
<li><a href="../plug-ins/sorting_auto.html">Sorting plug-ins (with type detection)</a></li>
<li><a href="../plug-ins/sorting_manual.html">Sorting plug-ins (no type detection)</a></li>
<li><a href="../plug-ins/range_filtering.html">Sorting plug-ins (with type detection)</a></li>
<li><a href="../plug-ins/dom_sort.html">Live DOM sorting</a></li>
</ul>
</section>
</div>
</body>
</html>