mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Optimized HEADER FILTER in tabulator to use COMPARISON OPERATORS
Now header filter parses the given filterstring. If it starts with a comparison operator it will be used for comparison. Otherwise just compare the stringnumbers to be equal.
This commit is contained in:
@@ -127,15 +127,26 @@ $this->load->view(
|
||||
// Header filter
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Casts string formatted float values to float when using the filter.
|
||||
// This will allow correct filtering.
|
||||
function hf_compareWithFloat(headerValue, rowValue, rowData, filterParams){
|
||||
//headerValue - the value of the header filter element
|
||||
//rowValue - the value of the column in this row
|
||||
//rowData - the data for the row being filtered
|
||||
//filterParams - params object passed to the headerFilterFuncParams property
|
||||
// Filters values using comparison operator or just by string comparison
|
||||
function hf_filterStringnumberWithOperator(headerValue, rowValue, rowData){
|
||||
|
||||
return parseFloat(headerValue) <= parseFloat(rowValue); //must return a boolean, true if it passes the filter.
|
||||
// If string starts with <, <=, >, >=, !=, ==, compare values with that operator
|
||||
var operator = '';
|
||||
if (headerValue.match(/([<=>!]{1,2})/g)) {
|
||||
var operator_arr = headerValue.match(/([<=>!]{1,2})/g);
|
||||
operator = operator_arr[0];
|
||||
|
||||
headerValue = headerValue
|
||||
.replace(operator, '')
|
||||
.trim()
|
||||
;
|
||||
|
||||
// return if value comparison is true
|
||||
return eval(rowValue + operator + headerValue);
|
||||
}
|
||||
|
||||
// If just a stringnumber, return if exact match found
|
||||
return parseFloat(rowValue) == headerValue;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -358,8 +358,11 @@ $filterWidgetArray = array(
|
||||
semester: {headerFilter:"input"},
|
||||
lv_oe_kurzbz: {headerFilter:"input", width: "12%"},
|
||||
gruppe: {headerFilter:"input", width: "5%"},
|
||||
stunden: {align:"right", headerFilter:"input", bottomCalc:"sum", bottomCalcParams:{precision:1}, width: "5%"},
|
||||
betrag: {align:"right", headerFilter:"input", headerFilterPlaceholder:">=", headerFilterFunc: hf_compareWithFloat,
|
||||
stunden: {align:"right",
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:1}, width: "5%"},
|
||||
betrag: {align:"right",
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"},
|
||||
width: "8%"},
|
||||
vertrag_id: {visible: false},
|
||||
|
||||
@@ -146,15 +146,26 @@ $this->load->view(
|
||||
// Header filter
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Casts string formatted float values to float when using the filter.
|
||||
// This will allow correct filtering.
|
||||
function hf_compareWithFloat(headerValue, rowValue, rowData, filterParams){
|
||||
//headerValue - the value of the header filter element
|
||||
//rowValue - the value of the column in this row
|
||||
//rowData - the data for the row being filtered
|
||||
//filterParams - params object passed to the headerFilterFuncParams property
|
||||
// Filters values using comparison operator or just by string comparison
|
||||
function hf_filterStringnumberWithOperator(headerValue, rowValue, rowData){
|
||||
|
||||
return parseFloat(headerValue) <= parseFloat(rowValue); //must return a boolean, true if it passes the filter.
|
||||
// If string starts with <, <=, >, >=, !=, ==, compare values with that operator
|
||||
var operator = '';
|
||||
if (headerValue.match(/([<=>!]{1,2})/g)) {
|
||||
var operator_arr = headerValue.match(/([<=>!]{1,2})/g);
|
||||
operator = operator_arr[0];
|
||||
|
||||
headerValue = headerValue
|
||||
.replace(operator, '')
|
||||
.trim()
|
||||
;
|
||||
|
||||
// return if value comparison is true
|
||||
return eval(rowValue + operator + headerValue);
|
||||
}
|
||||
|
||||
// If just a stringnumber, return if exact match found
|
||||
return parseFloat(rowValue) == headerValue;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -377,8 +377,11 @@ $filterWidgetArray = array(
|
||||
lv_oe_kurzbz: {headerFilter:"input"},
|
||||
gruppe: {headerFilter:"input"},
|
||||
lektor: {headerFilter:"input"},
|
||||
stunden: {align:"right", headerFilter:"input", bottomCalc:"sum", bottomCalcParams:{precision:1}},
|
||||
betrag: {align:"right", headerFilter:"input", headerFilterPlaceholder:">=", headerFilterFunc: hf_compareWithFloat,
|
||||
stunden: {align:"right",
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:1}},
|
||||
betrag: {align:"right",
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money", bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}},
|
||||
vertrag_id: {visible: false},
|
||||
vertrag_betrag: {visible: false},
|
||||
|
||||
@@ -144,15 +144,26 @@ $this->load->view(
|
||||
// Header filter
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Casts string formatted float values to float when using the filter.
|
||||
// This will allow correct filtering.
|
||||
function hf_compareWithFloat(headerValue, rowValue, rowData, filterParams){
|
||||
//headerValue - the value of the header filter element
|
||||
//rowValue - the value of the column in this row
|
||||
//rowData - the data for the row being filtered
|
||||
//filterParams - params object passed to the headerFilterFuncParams property
|
||||
// Filters values using comparison operator or just by string comparison
|
||||
function hf_filterStringnumberWithOperator(headerValue, rowValue, rowData){
|
||||
|
||||
return parseFloat(headerValue) <= parseFloat(rowValue); //must return a boolean, true if it passes the filter.
|
||||
// If string starts with <, <=, >, >=, !=, ==, compare values with that operator
|
||||
var operator = '';
|
||||
if (headerValue.match(/([<=>!]{1,2})/g)) {
|
||||
var operator_arr = headerValue.match(/([<=>!]{1,2})/g);
|
||||
operator = operator_arr[0];
|
||||
|
||||
headerValue = headerValue
|
||||
.replace(operator, '')
|
||||
.trim()
|
||||
;
|
||||
|
||||
// return if value comparison is true
|
||||
return eval(rowValue + operator + headerValue);
|
||||
}
|
||||
|
||||
// If just a stringnumber, return if exact match found
|
||||
return parseFloat(rowValue) == headerValue;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -388,11 +388,11 @@ $filterWidgetArray = array(
|
||||
gruppe: {headerFilter:"input"},
|
||||
lektor: {headerFilter:"input"},
|
||||
stunden: {align:"right",
|
||||
headerFilter:"input", headerFilterPlaceholder:">=", headerFilterFunc: hf_compareWithFloat,
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:1}},
|
||||
stundensatz: {visible: false},
|
||||
betrag: {align:"right",
|
||||
headerFilter:"input", headerFilterPlaceholder:">=", headerFilterFunc: hf_compareWithFloat,
|
||||
headerFilter:"input", headerFilterFunc: hf_filterStringnumberWithOperator,
|
||||
bottomCalc:"sum", bottomCalcParams:{precision:2}, bottomCalcFormatter:"money",
|
||||
bottomCalcFormatterParams:{decimal: ",", thousand: ".", symbol:"€"}},
|
||||
vertrag_id: {visible: false},
|
||||
|
||||
Reference in New Issue
Block a user