Custom-Filters
Custom-Filters
Hi Allan,
I have a report with 19 columns. I have the global quick filters in the footer of the table. The problem is that there are three number fields for which I need custom-filters to return the entered number or anything greater than that for e.g. if the user typed 1 it should filter 1, 2, 3, 4... all numbers equal to or greater than 1. I attempted to write the code for the custom-filters myself and it will take 19X19 = 361 conditions to cater for all the possibilities. Is there a simpler and better way to accomplish this where I can use the in-built filters and the custom-filtering for these three number fields?
This is the code for when the user just filters one field at a time. Any help would be greatly appreciated. Thanks a lot.
Best regards,
Ali
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, Data, iDataIndex) {
var FacilityData = Data[0],
FacilityTypeData = Data[1],
ATCLevelData = Data[2],
EffectiveDateData = new Date(Data[3]),
ClassBData = Data[4],
ClassCData = Data[5],
ClassDData = Data[6],
ARSAData = Data[7],
TRSAData = Data[8],
SingleData = Data[9],
ParallelData = Data[10],
CrossingData = Data[11],
ConvergingData = Data[12],
TowerMountainousData = Data[13],
TowerForeignData = Data[14],
ASOSData = Data[15],
LAWRSData = Data[16],
ProximityData = Data[17],
TRACONMountainousData = Data[18],
TRACONForeignData = Data[19]
var Filter = {
Facility: document.getElementById('FacilitySearch').value,
FacilityType: document.getElementById('FacilityTypeSearch').value,
ATCLevel: document.getElementById('ATCLevelSearch').value,
EffectiveDate: new Date(document.getElementById('EffectiveDateSearch').value),
ClassB: document.getElementById('ClassBSearch').value,
ClassC: document.getElementById('ClassCSearch').value,
ClassD: document.getElementById('ClassDSearch').value,
ARSA: document.getElementById('ARSASearch').value,
TRSA: document.getElementById('TRSASearch').value,
Single: document.getElementById('SingleSearch').value,
Parallel: document.getElementById('ParallelSearch').value,
Crossing: document.getElementById('CrossingSearch').value,
Converging: document.getElementById('ConvergingSearch').value,
TowerMountainous: document.getElementById('TowerMountainousSearch').value,
TowerForeign: document.getElementById('TowerForeignSearch').value,
ASOS: document.getElementById('ASOSSearch').value,
LAWRS: document.getElementById('LAWRSSearch').value,
Proximity: document.getElementById('ProximitySearch').value,
TRACONMountainous: document.getElementById('TRACONMountainousSearch').value,
TRACONForeign: document.getElementById('TRACONForeignSearch').value
}
Filter.Facility = Filter.Facility.toUpperCase();
Filter.ClassB = Filter.ClassB.toUpperCase();
Filter.ClassC = Filter.ClassC.toUpperCase();
Filter.ClassD = Filter.ClassD.toUpperCase();
Filter.ARSA = Filter.ARSA.toUpperCase();
Filter.TRSA = Filter.TRSA.toUpperCase();
Filter.Single = Filter.Single.toUpperCase();
Filter.Parallel = Filter.Parallel.toUpperCase();
Filter.Crossing = Filter.Crossing.toUpperCase();
Filter.Converging = Filter.Converging.toUpperCase();
Filter.TowerMountainous = Filter.TowerMountainous.toUpperCase();
Filter.ASOS = Filter.ASOS.toUpperCase();
Filter.LAWRS = Filter.LAWRS.toUpperCase();
Filter.TRACONMountainous = Filter.TRACONMountainous.toUpperCase();
ClassBData = ClassBData.toUpperCase();
ClassCData = ClassCData.toUpperCase();
ClassDData = ClassDData.toUpperCase();
ARSAData = ARSAData.toUpperCase();
TRSAData = TRSAData.toUpperCase();
SingleData = SingleData.toUpperCase();
ParallelData = ParallelData.toUpperCase();
CrossingData = CrossingData.toUpperCase();
ConvergingData = ConvergingData.toUpperCase();
TowerMountainousData = TowerMountainousData.toUpperCase();
ASOSData = ASOSData.toUpperCase();
LAWRSData = LAWRSData.toUpperCase();
TRACONMountainousData = TRACONMountainousData.toUpperCase();
var FoundMatch = false;
if (Filter.Facility == "" && Filter.FacilityType == "" && Filter.ATCLevel == "" && Filter.EffectiveDate == 'NaN' &&
Filter.ClassB == "" && Filter.ClassC == "" && Filter.ClassD == "" && Filter.ARSA == "" &&
Filter.TRSA == "" && Filter.Single == "" && Filter.Parallel == "" && Filter.Crossing == "" &&
Filter.Converging == "" && Filter.TowerMountainous == "" && Filter.TowerForeign == "" && Filter.ASOS == "" &&
Filter.LAWRS == "" && Filter.Proximity == "" && Filter.TRACONMountainous == "" && Filter.TRACONForeign == "") {
return true;
}
All blank
if (Filter.Facility == "" && Filter.FacilityType == "" && Filter.ATCLevel == "" && Filter.EffectiveDate == 'NaN' &&
Filter.ClassB == "" && Filter.ClassC == "" && Filter.ClassD == "" && Filter.ARSA == "" &&
Filter.TRSA == "" && Filter.Single == "" && Filter.Parallel == "" && Filter.Crossing == "" &&
Filter.Converging == "" && Filter.TowerMountainous == "" && Filter.TowerForeign == "" && Filter.ASOS == "" &&
Filter.LAWRS == "" && Filter.Proximity == "" && Filter.TRACONMountainous == "" && Filter.TRACONForeign == "") {
return true;
} // Facility
else if (FacilityData.indexOf(Filter.Facility) > -1 && Filter.FacilityType == "" && Filter.ATCLevel == "" && Filter.EffectiveDate == "NaN" &&
Filter.ClassB == "" && Filter.ClassC == "" && Filter.ClassD == "" && Filter.ARSA == "" &&
Filter.TRSA == "" && Filter.Single == "" && Filter.Parallel == "" && Filter.Crossing == "" &&
Filter.Converging == "" && Filter.TowerMountainous == "" && Filter.TowerForeign == "" && Filter.ASOS == "" &&
Filter.LAWRS == "" && Filter.Proximity == "" && Filter.TRACONMountainous == "" && Filter.TRACONForeign == "") {
return true;
} // FacilityType
else if (Filter.Facility == "" && Filter.FacilityType == FacilityTypeData && Filter.ATCLevel == "" && Filter.EffectiveDate == "" &&
Filter.ClassB == "" && Filter.ClassC == "" && Filter.ClassD == "" && Filter.ARSA == "" &&
Filter.TRSA == "" && Filter.Single == "" && Filter.Parallel == "" && Filter.Crossing == "" &&
Filter.Converging == "" && Filter.TowerMountainous == "" && Filter.TowerForeign == "" && Filter.ASOS == "" &&
Filter.LAWRS == "" && Filter.Proximity == "" && Filter.TRACONMountainous == "" && Filter.TRACONForeign == "") {
return true;
} // ATCLevel