パラメータは、bSort
デフォルトで「true」に設定されています
var ColumnFilterWidget = function( $Container, oDataTableSettings, i, widgets ) {
...
}
設定"bsort": false
は評価されないため、無視されます。適用するには、上記の関数を変更して追加する必要があります。
if ( 'bSort' in oDataTableSettings.oInit.oColumnFilterWidgets ) {
widget.bSort = oDataTableSettings.oInit.oColumnFilterWidgets.bSort;
}
直後の
if ( 'oColumnFilterWidgets' in oDataTableSettings.oInit ) {
最終的な関数は次のようになります。
var ColumnFilterWidget = function( $Container, oDataTableSettings, i, widgets ) {
var widget = this, sTargetList;
widget.iColumn = i;
widget.oColumn = oDataTableSettings.aoColumns[i];
widget.$Container = $Container;
widget.oDataTable = oDataTableSettings.oInstance;
widget.asFilters = [];
widget.sSeparator = '';
widget.bSort = true;
widget.iMaxSelections = -1;
if ( 'oColumnFilterWidgets' in oDataTableSettings.oInit ) {
if ( 'bSort' in oDataTableSettings.oInit.oColumnFilterWidgets ) {
widget.bSort = oDataTableSettings.oInit.oColumnFilterWidgets.bSort;
}
if ( 'sSeparator' in oDataTableSettings.oInit.oColumnFilterWidgets ) {
widget.sSeparator = oDataTableSettings.oInit.oColumnFilterWidgets.sSeparator;
}
if ( 'iMaxSelections' in oDataTableSettings.oInit.oColumnFilterWidgets ) {
widget.iMaxSelections = oDataTableSettings.oInit.oColumnFilterWidgets.iMaxSelections;
}
if ( 'aoColumnDefs' in oDataTableSettings.oInit.oColumnFilterWidgets ) {
$.each( oDataTableSettings.oInit.oColumnFilterWidgets.aoColumnDefs, function( iIndex, oColumnDef ) {
var sTargetList = '|' + oColumnDef.aiTargets.join( '|' ) + '|';
if ( sTargetList.indexOf( '|' + i + '|' ) >= 0 ) {
$.each( oColumnDef, function( sDef, oDef ) {
widget[sDef] = oDef;
} );
}
} );
}
}
widget.$Select = $( '<select></select>' ).change( function() {
var sSelected = widget.$Select.val(), sText, $TermLink, $SelectedOption;
if ( '' === sSelected ) {
// The blank option is a default, not a filter, and is re-selected after filtering
return;
}
sText = $( '<div>' + sSelected + '</div>' ).text();
$TermLink = $( '<a class="filter-term" href="#"></a>' )
.addClass( 'filter-term-' + sText.toLowerCase().replace( /\W/g, '' ) )
.text( sText )
.click( function() {
// Remove from current filters array
widget.asFilters = $.grep( widget.asFilters, function( sFilter ) {
return sFilter != sSelected;
} );
$TermLink.remove();
if ( widgets.$TermContainer && 0 === widgets.$TermContainer.find( '.filter-term' ).length ) {
widgets.$TermContainer.hide();
}
// Add it back to the select
widget.$Select.append( $( '<option></option>' ).attr( 'value', sSelected ).text( sText ) );
if ( widget.iMaxSelections > 0 && widget.iMaxSelections > widget.asFilters.length ) {
widget.$Select.attr( 'disabled', false );
}
widget.fnFilter();
return false;
} );
widget.asFilters.push( sSelected );
if ( widgets.$TermContainer ) {
widgets.$TermContainer.show();
widgets.$TermContainer.prepend( $TermLink );
} else {
widget.$Select.after( $TermLink );
}
$SelectedOption = widget.$Select.children( 'option:selected' );
widget.$Select.val( '' );
$SelectedOption.remove();
if ( widget.iMaxSelections > 0 && widget.iMaxSelections <= widget.asFilters.length ) {
widget.$Select.attr( 'disabled', true );
}
widget.fnFilter();
} );
widget.$Container.append( widget.$Select );
widget.fnDraw();
};