mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-30 23:52:11 +01:00
Fix: HTML column type could sometimes be overridden by the string sorting type. If a cell was found to have just a string and no HTML in it then the whole column would be treated as a string column, even if other cells had HTML. Now put a check in place to ensure that string can't overrule html type. Unit test added.
This commit is contained in:
parent
856bef205d
commit
5131e1dd7f
5
media/js/jquery.dataTables.js
vendored
5
media/js/jquery.dataTables.js
vendored
@ -2709,7 +2709,7 @@
|
||||
{
|
||||
oCol.sType = sThisType;
|
||||
}
|
||||
else if ( oCol.sType != sThisType )
|
||||
else if ( oCol.sType != sThisType && oCol.sType != "html" )
|
||||
{
|
||||
/* String is always the 'fallback' option */
|
||||
oCol.sType = 'string';
|
||||
@ -2913,7 +2913,8 @@
|
||||
{
|
||||
oSettings.aoColumns[iColumn].sType = sThisType;
|
||||
}
|
||||
else if ( oSettings.aoColumns[iColumn].sType != sThisType )
|
||||
else if ( oSettings.aoColumns[iColumn].sType != sThisType &&
|
||||
oSettings.aoColumns[iColumn].sType != "html" )
|
||||
{
|
||||
/* String is always the 'fallback' option */
|
||||
oSettings.aoColumns[iColumn].sType = 'string';
|
||||
|
66
media/unit_testing/templates/html_table.php
Normal file
66
media/unit_testing/templates/html_table.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
|
||||
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
|
||||
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
|
||||
header( 'Cache-Control: post-check=0, pre-check=0', false );
|
||||
header( 'Pragma: no-cache' );
|
||||
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" />
|
||||
|
||||
<title>DataTables unit testing</title>
|
||||
<style type="text/css" title="currentStyle">
|
||||
@import "../../css/demo_page.css";
|
||||
@import "../../css/demo_table.css";
|
||||
</style>
|
||||
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="../unit_test.js"></script>
|
||||
<?php
|
||||
$aScripts = explode( ":", $_GET['scripts'] );
|
||||
for ( $i=0 ; $i<count($aScripts) ; $i++ )
|
||||
{
|
||||
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n";
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body id="dt_example">
|
||||
<div id="container">
|
||||
<div class="full_width big">
|
||||
<i>DataTables</i> table with HTML elements template
|
||||
</div>
|
||||
|
||||
<h1>Live example</h1>
|
||||
<div id="demo">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Reflection</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td><a href="http://www.sprymedia.co.uk/article/DataTables">DataTables</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td><a href="http://www.sprymedia.co.uk/article/Integrity">A link to Integrity</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td><a href="http://www.sprymedia.co.uk/article/Integrity">Integrity</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>EIntegrity</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
57
media/unit_testing/tests_onhold/1_dom/html-autodetect-sort.js
Executable file
57
media/unit_testing/tests_onhold/1_dom/html-autodetect-sort.js
Executable file
@ -0,0 +1,57 @@
|
||||
// DATA_TEMPLATE: html_table
|
||||
oTest.fnStart( "HTML auto detect" );
|
||||
|
||||
$(document).ready( function () {
|
||||
var oTable = $('#example').dataTable();
|
||||
|
||||
oTest.fnTest(
|
||||
"Initial sort",
|
||||
null,
|
||||
function () {
|
||||
var ret =
|
||||
$('#example tbody tr:eq(0) td:eq(0)').html() == '1' &&
|
||||
$('#example tbody tr:eq(1) td:eq(0)').html() == '2' &&
|
||||
$('#example tbody tr:eq(2) td:eq(0)').html() == '3';
|
||||
return ret;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"HTML sort",
|
||||
function () { $('#example thead th:eq(1)').click() },
|
||||
function () {
|
||||
var ret =
|
||||
$('#example tbody tr:eq(0) td:eq(0)').html() == '2' &&
|
||||
$('#example tbody tr:eq(1) td:eq(0)').html() == '1' &&
|
||||
$('#example tbody tr:eq(2) td:eq(0)').html() == '4';
|
||||
return ret;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"HTML reverse sort",
|
||||
function () { $('#example thead th:eq(1)').click() },
|
||||
function () {
|
||||
var ret =
|
||||
$('#example tbody tr:eq(0) td:eq(0)').html() == '3' &&
|
||||
$('#example tbody tr:eq(1) td:eq(0)').html() == '4' &&
|
||||
$('#example tbody tr:eq(2) td:eq(0)').html() == '1';
|
||||
return ret;
|
||||
}
|
||||
);
|
||||
|
||||
oTest.fnTest(
|
||||
"Numeric sort",
|
||||
function () { $('#example thead th:eq(0)').click() },
|
||||
function () {
|
||||
var ret =
|
||||
$('#example tbody tr:eq(0) td:eq(0)').html() == '1' &&
|
||||
$('#example tbody tr:eq(1) td:eq(0)').html() == '2' &&
|
||||
$('#example tbody tr:eq(2) td:eq(0)').html() == '3';
|
||||
return ret;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
oTest.fnComplete();
|
||||
} );
|
Loading…
x
Reference in New Issue
Block a user