parent
fa79071454
commit
fcabab93da
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* DataTables has a built in type called 'html' which will strip HTML tags
|
||||
* from a search string, but it doesn't cope with nested HTML inside another
|
||||
* element's attributes (for example DOM0 events with have HTML in them). This
|
||||
* plug-in function overrules the built-in method and provides complete HTML
|
||||
* tag removal. Note that this function is not included in DataTables by
|
||||
* default because it is slightly slower than the built-in method, which is
|
||||
* good enough for by far the majority of use cases.
|
||||
* @name html
|
||||
* @author <i>guillimon</i>
|
||||
*
|
||||
* @example
|
||||
* $(document).ready(function() {
|
||||
* var oTable = $('#example').dataTable({
|
||||
* "aoColumns": [
|
||||
* "sType": "html",
|
||||
* null
|
||||
* ]
|
||||
* });
|
||||
* } );
|
||||
*/
|
||||
|
||||
jQuery.fn.dataTableExt.ofnSearch['html'] = function ( sData ) {
|
||||
var n = document.createElement('div');
|
||||
n.innerHTML = sData;
|
||||
if ( n.textContent ) {
|
||||
return n.textContent.replace(/\n/g," ");
|
||||
} else {
|
||||
return n.innerText.replace(/\n/g," ");
|
||||
}
|
||||
};
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Filter a column on a specific date range. Note that you will likely need
|
||||
* to change the id's on the inputs and the columns in which the start and
|
||||
* end date exist.
|
||||
* @name Range filtering (dates)
|
||||
* @author <i>guillimon</i>
|
||||
*
|
||||
* @example
|
||||
* $(document).ready(function() {
|
||||
* var oTable = $('#example').dataTable();
|
||||
*
|
||||
* // Add event listeners to the two range filtering inputs
|
||||
* $('#min').keyup( function() { oTable.fnDraw(); } );
|
||||
* $('#max').keyup( function() { oTable.fnDraw(); } );
|
||||
* } );
|
||||
*/
|
||||
|
||||
$.fn.dataTableExt.afnFiltering.push(
|
||||
function( oSettings, aData, iDataIndex ) {
|
||||
var iFini = document.getElementById('fini').value;
|
||||
var iFfin = document.getElementById('ffin').value;
|
||||
var iStartDateCol = 6;
|
||||
var iEndDateCol = 7;
|
||||
|
||||
iFini=iFini.substring(6,10) + iFini.substring(3,5)+ iFini.substring(0,2)
|
||||
iFfin=iFfin.substring(6,10) + iFfin.substring(3,5)+ iFfin.substring(0,2)
|
||||
|
||||
var datofini=aData[iStartDateCol].substring(6,10) + aData[iStartDateCol].substring(3,5)+ aData[iStartDateCol].substring(0,2);
|
||||
var datoffin=aData[iEndDateCol].substring(6,10) + aData[iEndDateCol].substring(3,5)+ aData[iEndDateCol].substring(0,2);
|
||||
|
||||
if ( iFini == "" && iFfin == "" )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( iFini <= datofini && iFfin == "")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( iFfin >= datoffin && iFini == "")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (iFini <= datofini && iFfin >= datoffin)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Filter a specific numeric column on the value being between two given
|
||||
* numbers. Note that you will likely need to change the id's on the inputs
|
||||
* and the column in which the numeric value is given.
|
||||
* @name Range filtering (numbers)
|
||||
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a>
|
||||
*
|
||||
* @example
|
||||
* $(document).ready(function() {
|
||||
* // Initialise datatables
|
||||
* var oTable = $('#example').dataTable();
|
||||
*
|
||||
* // Add event listeners to the two range filtering inputs
|
||||
* $('#min').keyup( function() { oTable.fnDraw(); } );
|
||||
* $('#max').keyup( function() { oTable.fnDraw(); } );
|
||||
* } );
|
||||
*/
|
||||
|
||||
jQuery.fn.dataTableExt.afnFiltering.push(
|
||||
function( oSettings, aData, iDataIndex ) {
|
||||
var iColumn = 3;
|
||||
var iMin = document.getElementById('min').value * 1;
|
||||
var iMax = document.getElementById('max').value * 1;
|
||||
|
||||
var iVersion = aData[iColumn] == "-" ? 0 : aData[iColumn]*1;
|
||||
if ( iMin == "" && iMax == "" )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( iMin == "" && iVersion < iMax )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( iMin < iVersion && "" == iMax )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( iMin < iVersion && iVersion < iMax )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
Loading…
Reference in new issue