diff --git a/js/core/core.data.js b/js/core/core.data.js index b96969238..5db24b28f 100644 --- a/js/core/core.data.js +++ b/js/core/core.data.js @@ -618,7 +618,13 @@ function _fnGetRowElements( settings, row, colIdx, d ) var cellProcess = function ( cell ) { if ( colIdx === undefined || colIdx === i ) { col = columns[i]; - contents = $.trim(cell.innerHTML); + //if specified, ignore additional markup and only store innerText as data + if(col.stripHTML){ + contents = (cell.innerText)? cell.innerText.trim(): ''; + } + else{ + contents = (cell.innerHTML)? cell.innerHTML.trim(): ''; + } if ( col && col._bAttrSrc ) { var setter = _fnSetObjectDataFn( col.mData._ ); diff --git a/js/model/model.defaults.columns.js b/js/model/model.defaults.columns.js index 0d10b4305..834ebc21f 100644 --- a/js/model/model.defaults.columns.js +++ b/js/model/model.defaults.columns.js @@ -703,6 +703,35 @@ DataTable.defaults.column = { */ "sName": "", + + /** + * Defines whether the cell data includes the HTML content or not. + * This means that when the data contents of the cell are set, the innerText property is used rather than innerHTML. + * + * This is useful in environments where table data may be embedded in multiple levels of HTML after the element for two reasons:- + * -DataTables extensions such as searchPanes can compare cell data without comparing HTML data. + * -Performance increase for processing tables which have a large amount of additional markup as less data is saved to memory. * + * + * @name DataTable.defaults.column.stripHTML + * @type bool + * @default false + * + * @example + * // Using `columnDefs` + * $(document).ready( function() { + * $('#example').dataTable( { + * "columnDefs": [ + * { + * stripHTML: true, + * targets : '_all' + * } + * ] + * } ); + * } ); + * + */ + "stripHTML": false + /** * Defines a data source type for the ordering which can be used to read