Используя DataTables 1.10.19 и этот плагин , я использую атрибут alt
в качестве данных для сортировки.
Это работает;
{
targets: [7],
type: 'alt-string',
render: function(data, type, row) {
if (data == 1) {
return '<a href="example.com"><i class="icon-ok" alt="Processed"></i></a>';
}
}
}
Это не работает;
{
targets: [7],
type: 'alt-string',
render: function(data, type, row) {
if (data == 1) {
return '<a href="example.com?id=' + row[0] + '&approvalcode=' + row[9] + '"><i class="icon-ok" alt="Processed"></i></a>';
}
}
}
Кажется, что когда я добавляю в строки запроса URL row
, это нарушаетalt
фильтр, хотя все остальное работает как положено.
Код плагина ниже;
/**
* Sort on the 'alt' tag of images in a column. This is particularly useful if
* you have a column of images (ticks and crosses for example) and you want to
* control the sorting using the alt tag.
*
* @name Alt string
* @summary Use the `alt` attribute of an image tag as the data to sort upon.
* @author _Jumpy_
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'alt-string', targets: 0 }
* ]
* } );
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"alt-string-pre": function ( a ) {
return a.match(/alt="(.*?)"/)[1].toLowerCase();
},
"alt-string-asc": function( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"alt-string-desc": function(a,b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );