Skip to content

Commit 3d5a8a4

Browse files
committed
Fix #2: Corrected issue with ordering of cells containing HTML tags
1 parent dba309b commit 3d5a8a4

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

js/dataTables.alphabetSearch.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! AlphabetSearch for DataTables v1.2.3
1+
/*! AlphabetSearch for DataTables v1.2.4
22
* 2014 SpryMedia Ltd - datatables.net/license
33
* Gyrocode - MIT License
44
*/
@@ -7,7 +7,7 @@
77
* @summary AlphabetSearch
88
* @description Show an set of alphabet buttons alongside a table providing
99
* search input options
10-
* @version 1.2.3
10+
* @version 1.2.4
1111
* @file dataTables.alphabetSearch.js
1212
* @author SpryMedia Ltd (www.sprymedia.co.uk)
1313
* @contact www.sprymedia.co.uk/contact
@@ -94,28 +94,29 @@ $.fn.dataTable.ext.order['alphabetSearch'] = function ( context, col )
9494
}
9595

9696
var data = this.api().column( col, { order: 'index' } ).data().map( function (value, index) {
97+
var letter = value.replace(/<.*?>/g, '').charAt(0).toUpperCase();
98+
9799
// If sorting by alphabetized column
98100
return (order_col === context.alphabetSearch.column)
99-
? (
100-
// If first pass
101-
( !context.alphabetSearch.pass )
102-
// Ignore
103-
?
104-
''
105-
// Otherwise, if it's a second pass
106-
:
107-
(
108-
// If method is ascending sort
109-
( order_method === 'asc' )
110-
// Return first letter
111-
? value.charAt(0)
112-
: String.fromCharCode(65535 - value.charCodeAt(0))
113-
)
114-
)
115-
// Otherwise, if sorting by column other than the one being alphabetized,
116-
// return first letter
117-
: value.charAt(0);
118-
101+
? (
102+
// If first pass
103+
( !context.alphabetSearch.pass )
104+
// Ignore
105+
?
106+
''
107+
// Otherwise, if it's a second pass
108+
:
109+
(
110+
// If method is ascending sort
111+
( order_method === 'asc' )
112+
// Return first letter
113+
? letter
114+
: String.fromCharCode(65535 - letter.charCodeAt(0))
115+
)
116+
)
117+
// Otherwise, if sorting by column other than the one being alphabetized,
118+
// return first letter
119+
: letter;
119120
} );
120121

121122
// If sorting by alphabetized column

js/dataTables.alphabetSearch.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)