1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-20 14:45:15 +02:00

Merge pull request #429 from koalyptus/simplify-get-data-apis

Simplify get data apis
This commit is contained in:
koalyptus 2017-04-02 10:49:03 +10:00 committed by GitHub
commit f0e2ec6a8a
19 changed files with 342 additions and 66 deletions

4
dist/starter.html vendored
View file

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tablefilter v0.5.4 - Starter</title>
<title>tablefilter v0.5.5 - Starter</title>
</head>
<body>
<h1>tablefilter v0.5.4</h1>
<h1>tablefilter v0.5.5</h1>

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.4 by Max Guglielmi
* build date: 2017-03-25T04:13:19.149Z
* tablefilter v0.5.5 by Max Guglielmi
* build date: 2017-04-01T13:45:26.426Z
* MIT License
*/
table.TF{padding:0;color:inherit;border-right:1px solid transparent;border-top:1px solid transparent;border-left:1px solid transparent;border-bottom:0;}table.TF th{margin:0;color:inherit;background-color:transparent;border-color:transparent;border-width:1px;border-style:solid;}table.TF th:last-child{border-right:1px solid transparent}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid transparent;border-left:0;border-top:0;border-right:0}.fltrow{background-color:transparent;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px;border-bottom:1px solid transparent !important;}.fltrow th:last-child,.fltrow td:last-child{border-right:1px solid transparent}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4}input.flt{width:99% !important}.inf{background-color:transparent;border:1px solid transparent;height:$min-height;color:inherit}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#f7f7f7 url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#f7f7f7 url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#f7f7f7 url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#f7f7f7 url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.activeHeader{background:#f7f7f7 !important;border:1px solid transparent;color:inherit !important}div.grd_Cont{-webkit-box-shadow:0 0 0 0 rgba(50,50,50,0.75);-moz-box-shadow:0 0 0 0 rgba(50,50,50,0.75);box-shadow:0 0 0 0 rgba(50,50,50,0.75);background-color:transparent;border:1px solid transparent;padding:0 !important;}div.grd_Cont .even{background-color:transparent}div.grd_Cont .odd{background-color:#f7f7f7}div.grd_headTblCont{background-color:transparent;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:transparent;border-bottom:1px solid transparent;border-right:1px solid transparent !important;border-left:1px solid transparent;border-top:1px solid transparent}div.grd_tblCont table td{border-bottom:1px solid transparent;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:transparent;color:inherit;border-top:1px solid transparent;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#f7f7f7;border:1px solid #f7f7f7;border-radius:5px;color:#000;text-shadow:none}.even{background-color:transparent}.odd{background-color:#f7f7f7}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ccc !important;color:inherit}.ezSelectedRow{background-color:#ccc !important;color:inherit}.ezActiveCell{background-color:transparent;color:inherit;font-weight:bold}.ezETSelectedCell{background-color:transparent;font-weight:bold;color:inherit}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.5.4",
"version": "0.5.5",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {

View file

@ -172,7 +172,7 @@ export default class ColOps extends Feature {
//use uIndexes because we only want to pass through this loop
//once for each column get the values in this unique column
colValues.push(
tf.getFilteredDataCol(uIndexes[u], false, true, excludeRows)
tf.getVisibleColumnData(uIndexes[u], false, excludeRows)
);
let curValues = colValues[u];
@ -256,8 +256,8 @@ export default class ColOps extends Feature {
*/
columnCalc(colIndex, operation = SUM, precision) {
let excludeRows = this.excludeRows || [];
let colValues =
this.tf.getFilteredDataCol(colIndex, false, true, excludeRows);
let colValues = tf.getVisibleColumnData(colIndex, false, excludeRows);
return Number(this.calc(colValues, operation, precision));
}

View file

@ -281,7 +281,7 @@ export class CheckList extends Feature {
let filteredCol = filteredDataCol[j];
if (isLinked && tf.disableExcludedOptions) {
if (!filteredCol) {
filteredCol = tf.getFilteredDataCol(j);
filteredCol = tf.getVisibleColumnValues(j);
}
if (!has(filteredCol, cellString, caseSensitive) &&
!has(this.excludedOpts, cellString,

View file

@ -240,7 +240,7 @@ export class Dropdown extends Feature {
if (isLinked && tf.disableExcludedOptions) {
let filteredCol = filteredDataCol[j];
if (!filteredCol) {
filteredCol = tf.getFilteredDataCol(j);
filteredCol = tf.getVisibleColumnValues(j);
}
if (!has(filteredCol, cellString, tf.caseSensitive) &&
!has(excludedOpts, cellString, tf.caseSensitive)) {

View file

@ -2065,13 +2065,36 @@ export class TableFilter {
return occurence;
}
/**
* Return the data of a specified column
* @param {Number} colIndex Column index
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Arrat} [exclude=[]] List of row indexes to be excluded
* @returns Flat list of data for a column
*/
getColumnData(colIndex, includeHeaders = false, exclude = []) {
return this.getColValues(colIndex, includeHeaders, true, exclude);
}
/**
* Return the values of a specified column
* @param {Number} colIndex Column index
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Arrat} [exclude=[]] List of row indexes to be excluded
* @returns Flat list of values for a column
*/
getColumnValues(colIndex, includeHeaders = false, exclude = []) {
return this.getColValues(colIndex, includeHeaders, false, exclude);
}
/**
* Return the data of a specified column
* @param {Number} colIndex Column index
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Boolean} [typed=true] Return a typed value
* @param {Boolean} [typed=false] Return a typed value
* @param {Array} [exclude=[]] List of row indexes to be excluded
* @return {Array} Flat list of data for a column
* @private
*/
getColValues(
colIndex,
@ -2288,7 +2311,36 @@ export class TableFilter {
}
/**
* Return the table data with following format:
* Return the table data based on its columns data type definitions
* with following structure:
* [
* [rowIndex, [data0, data1...]],
* [rowIndex, [data0, data1...]]
* ]
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @returns {Array}
*/
getData(includeHeaders = false, excludeHiddenCols = false) {
return this.getTableData(includeHeaders, excludeHiddenCols, true);
}
/**
* Return the table values with following structure:
* [
* [rowIndex, [value0, value1...]],
* [rowIndex, [value0, value1...]]
* ]
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @returns {Array}
*/
getValues(includeHeaders = false, excludeHiddenCols = false) {
return this.getTableData(includeHeaders, excludeHiddenCols, false);
}
/**
* Return the table data with following structure:
* [
* [rowIndex, [value0, value1...]],
* [rowIndex, [value0, value1...]]
@ -2297,6 +2349,7 @@ export class TableFilter {
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @param {Boolean} [typed=false] Return typed value
* @return {Array}
* @private
*
* TODO: provide an API returning data in JSON format
*/
@ -2333,7 +2386,40 @@ export class TableFilter {
}
/**
* Return the filtered data with following format:
* Return the filtered table data based on its columns data type definitions
* with following structure:
* [
* [rowIndex, [data0, data1...]],
* [rowIndex, [data0, data1...]]
* ]
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @return {Array}
*
* TODO: provide an API returning data in JSON format
*/
getFilteredData(includeHeaders = false, excludeHiddenCols = false) {
return this.filteredData(includeHeaders, excludeHiddenCols, true);
}
/**
* Return the filtered table values with following structure:
* [
* [rowIndex, [value0, value1...]],
* [rowIndex, [value0, value1...]]
* ]
* @param {Boolean} [includeHeaders=false] Include headers row
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @return {Array}
*
* TODO: provide an API returning data in JSON format
*/
getFilteredValues(includeHeaders = false, excludeHiddenCols = false) {
return this.filteredData(includeHeaders, excludeHiddenCols, false);
}
/**
* Return the filtered data with following structure:
* [
* [rowIndex, [value0, value1...]],
* [rowIndex, [value0, value1...]]
@ -2342,15 +2428,16 @@ export class TableFilter {
* @param {Boolean} [excludeHiddenCols=false] Exclude hidden columns
* @param {Boolean} [typed=false] Return typed value
* @return {Array}
* @private
*
* TODO: provide an API returning data in JSON format
*/
getFilteredData(
filteredData(
includeHeaders = false,
excludeHiddenCols = false,
typed = false
) {
if (!this.validRowsIndex) {
if (this.validRowsIndex.length === 0) {
return [];
}
let rows = this.tbl.rows,
@ -2381,6 +2468,62 @@ export class TableFilter {
return filteredData;
}
/**
* Return the filtered data for a given column index
* @param {any} colIndex Colmun's index
* @param {boolean} [includeHeaders=false] Optional Include headers row
* @param {any} [exclude=[]] Optional List of row indexes to be excluded
* @returns {Array} Flat list of typed values [data0, data1, data2...]
*
* TODO: provide an API returning data in JSON format
*/
getFilteredColumnData(colIndex, includeHeaders = false, exclude = []) {
return this.getFilteredDataCol(
colIndex, includeHeaders, true, exclude, false);
}
/**
* Return the filtered and visible data for a given column index
* @param {any} colIndex Colmun's index
* @param {boolean} [includeHeaders=false] Optional Include headers row
* @param {any} [exclude=[]] Optional List of row indexes to be excluded
* @returns {Array} Flat list of typed values [data0, data1, data2...]
*
* TODO: provide an API returning data in JSON format
*/
getVisibleColumnData(colIndex, includeHeaders = false, exclude = []) {
return this.getFilteredDataCol(
colIndex, includeHeaders, true, exclude, true);
}
/**
* Return the filtered values for a given column index
* @param {any} colIndex Colmun's index
* @param {boolean} [includeHeaders=false] Optional Include headers row
* @param {any} [exclude=[]] Optional List of row indexes to be excluded
* @returns {Array} Flat list of values ['value0', 'value1', 'value2'...]
*
* TODO: provide an API returning data in JSON format
*/
getFilteredColumnValues(colIndex, includeHeaders = false, exclude = []) {
return this.getFilteredDataCol(
colIndex, includeHeaders, false, exclude, false);
}
/**
* Return the filtered and visible values for a given column index
* @param {any} colIndex Colmun's index
* @param {boolean} [includeHeaders=false] Optional Include headers row
* @param {any} [exclude=[]] Optional List of row indexes to be excluded
* @returns {Array} Flat list of values ['value0', 'value1', 'value2'...]
*
* TODO: provide an API returning data in JSON format
*/
getVisibleColumnValues(colIndex, includeHeaders = false, exclude = []) {
return this.getFilteredDataCol(
colIndex, includeHeaders, false, exclude, true);
}
/**
* Return the filtered data for a given column index
* @param {Number} colIndex Colmun's index
@ -2390,6 +2533,7 @@ export class TableFilter {
* @param {Boolean} [visible=true] Return only filtered and visible data
* (relevant for paging)
* @return {Array} Flat list of values ['val0','val1','val2'...]
* @private
*
* TODO: provide an API returning data in JSON format
*/
@ -2566,7 +2710,7 @@ export class TableFilter {
}
/**
* Makes defined rows always visible
* Make defined rows always visible
*/
enforceVisibility() {
if (!this.hasVisibleRows) {
@ -2604,7 +2748,7 @@ export class TableFilter {
}
/**
* Clears filtered columns visual indicator (background color)
* Clear filtered columns visual indicator (background color)
*/
clearActiveColumns() {
for (let i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) {
@ -2656,7 +2800,7 @@ export class TableFilter {
}
/**
* Builds filter element ID for a given column index
* Build filter element ID for a given column index
* @param {any} colIndex
* @returns {String} Filter element ID string
* @private
@ -2727,7 +2871,7 @@ export class TableFilter {
}
/**
* Determines if passed filter column implements exact query match
* Determine if passed filter column implements exact query match
* @param {Number} colIndex Column index
* @return {Boolean}
*/
@ -2738,7 +2882,7 @@ export class TableFilter {
}
/**
* Checks if passed row is valid
* Check if passed row is valid
* @param {Number} rowIndex Row index
* @returns {Boolean}
*/
@ -2747,7 +2891,7 @@ export class TableFilter {
}
/**
* Checks if passed row is visible
* Check if passed row is visible
* @param {Number} rowIndex Row index
* @returns {Boolean}
*/
@ -2757,7 +2901,7 @@ export class TableFilter {
}
/**
* Checks if specified column filter ignores diacritics.
* Check if specified column filter ignores diacritics.
* Note this is only applicable to input filter types.
* @param {Number} colIndex Column index
* @returns {Boolean}
@ -2771,7 +2915,7 @@ export class TableFilter {
}
/**
* Returns clear all text for specified filter column
* Return clear all text for specified filter column
* @param {Number} colIndex Column index
* @returns {String}
*/
@ -2860,7 +3004,7 @@ export class TableFilter {
/**
* Get list of filter IDs
* @return {[type]} [description]
* @return {Array} List of filters ids
*/
getFiltersId() {
return this.fltIds || [];

View file

@ -204,7 +204,7 @@ test('Get table data', function() {
tf.setFilterValue(0, 'Adelaide');
tf.filter();
deepEqual(
tf.getFilteredData(),
tf.getFilteredValues(),
[
[6, ['Adelaide','Perth','2781','3.1','38']],
[7, ['Adelaide','Alice Springs','1533','2','20.25']],
@ -213,7 +213,7 @@ test('Get table data', function() {
'Get filtered table data'
);
deepEqual(
tf.getFilteredData(true),
tf.getFilteredValues(true),
[
[1, ['From','Destination','Road Distance (km)',
'By Air (hrs)','By Rail (hrs)']],
@ -221,10 +221,10 @@ test('Get table data', function() {
[7, ['Adelaide','Alice Springs','1533','2','20.25']],
[8, ['Adelaide','Brisbane','2045','2.15','40']]
],
'Get filtered table data including columns headers'
'Get filtered table values including columns headers'
);
deepEqual(
tf.getFilteredData(false, false, true),
tf.getFilteredData(),
[
[6, ['Adelaide','Perth',2781,3.1,38]],
[7, ['Adelaide','Alice Springs',1533,2,20.25]],
@ -247,6 +247,46 @@ test('Get table data', function() {
[2781,1533,2045],
'Get specified column filtered typed values'
);
deepEqual(
tf.getFilteredColumnData(2),
[2781,1533,2045],
'Get filtered column data'
);
deepEqual(
tf.getFilteredColumnData(2, true),
['Road Distance (km)',2781,1533,2045],
'Get filtered column data with headers'
);
deepEqual(
tf.getVisibleColumnData(2),
[2781,1533,2045],
'Get visible column data'
);
deepEqual(
tf.getVisibleColumnData(2, true),
['Road Distance (km)',2781,1533,2045],
'Get visible column data with headers'
);
deepEqual(
tf.getFilteredColumnValues(2),
['2781','1533','2045'],
'Get filtered column data'
);
deepEqual(
tf.getFilteredColumnValues(2, true),
['Road Distance (km)','2781','1533','2045'],
'Get filtered column data with headers'
);
deepEqual(
tf.getVisibleColumnValues(2),
['2781','1533','2045'],
'Get visible column data'
);
deepEqual(
tf.getVisibleColumnValues(2, true),
['Road Distance (km)','2781','1533','2045'],
'Get visible column data with headers'
);
tf.clearFilters();
tf.filter();
});
@ -264,7 +304,8 @@ test('Test filter types', function() {
base_path: '../dist/tablefilter/',
col_0: 'select',
col_1: 'multiple',
col_2: 'checklist'
col_2: 'checklist',
col_types: ['string', 'string', 'number', 'number', 'number']
});
tf.init();
@ -348,7 +389,8 @@ test('Sanity checks', function() {
tf = null;
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
popup_filters: true
popup_filters: true,
col_types: ['string', 'string', 'number', 'number', 'number']
});
tf.init();
@ -396,7 +438,8 @@ test('Sanity checks', function() {
grid_layout: true,
col_0: 'select',
col_1: 'multiple',
col_2: 'checklist'
col_2: 'checklist',
col_types: ['string', 'string', 'number', 'number', 'number']
});
tf.init();
@ -456,6 +499,28 @@ test('Get table data', function() {
],
'Get specified column values including column header'
);
deepEqual(tf.getColumnValues(0),
[
'Sydney','Sydney','Sydney',
'Sydney','Adelaide','Adelaide','Adelaide'
],
'Get specified column values'
);
deepEqual(tf.getColumnValues(0, true),
[
'From','Sydney','Sydney','Sydney',
'Sydney','Adelaide','Adelaide','Adelaide'
],
'Get specified column values including column header'
);
deepEqual(tf.getColumnData(2),
[1412, 982, 286, 872, 2781, 1533, 2045],
'Get specified column data'
);
deepEqual(tf.getColumnData(2, true),
['Road Distance (km)', 1412, 982, 286, 872, 2781, 1533, 2045],
'Get specified column data including column header'
);
deepEqual(
tf.getTableData(),
[
@ -467,22 +532,49 @@ test('Get table data', function() {
[5, ['Adelaide','Alice Springs','1533','2','20.25']],
[6, ['Adelaide','Brisbane','2045','2.15','40']]
],
'Get table values with getTableData()'
);
deepEqual(
tf.getData(),
[
[0, ['Sydney','Adelaide',1412,1.4,25.3]],
[1, ['Sydney','Brisbane',982,1.5,16]],
[2, ['Sydney','Canberra',286,0.6,4.3]],
[3, ['Sydney','Melbourne',872,1.1,10.5]],
[4, ['Adelaide','Perth',2781,3.1,38]],
[5, ['Adelaide','Alice Springs',1533,2,20.25]],
[6, ['Adelaide','Brisbane',2045,2.15,40]]
],
'Get table data'
);
deepEqual(
tf.getValues(),
[
[0, ['Sydney','Adelaide','1412','1.4','25.3']],
[1, ['Sydney','Brisbane','982','1.5','16']],
[2, ['Sydney','Canberra','286','.6','4.3']],
[3, ['Sydney','Melbourne','872','1.1','10.5']],
[4, ['Adelaide','Perth','2781','3.1','38']],
[5, ['Adelaide','Alice Springs','1533','2','20.25']],
[6, ['Adelaide','Brisbane','2045','2.15','40']]
],
'Get table values'
);
tf.clearFilters();
tf.setFilterValue(0, 'Adelaide');
tf.filter();
deepEqual(
tf.getFilteredData(),
tf.getFilteredValues(),
[
[4, ['Adelaide','Perth','2781','3.1','38']],
[5, ['Adelaide','Alice Springs','1533','2','20.25']],
[6, ['Adelaide','Brisbane','2045','2.15','40']]
],
'Get filtered table data'
'Get filtered table values'
);
deepEqual(
tf.getFilteredData(true),
tf.getFilteredValues(true),
[
[0, ['From','Destination','Road Distance (km)',
'By Air (hrs)','By Rail (hrs)']],
@ -490,7 +582,7 @@ test('Get table data', function() {
[5, ['Adelaide','Alice Springs','1533','2','20.25']],
[6, ['Adelaide','Brisbane','2045','2.15','40']]
],
'Get filtered table data including columns headers'
'Get filtered table values including columns headers'
);
deepEqual(
tf.getFilteredDataCol(0),
@ -502,6 +594,46 @@ test('Get table data', function() {
['From','Adelaide','Adelaide','Adelaide'],
'Get specified column filtered values including header'
);
deepEqual(
tf.getFilteredColumnData(2),
[2781,1533,2045],
'Get filtered column data'
);
deepEqual(
tf.getFilteredColumnData(2, true),
['Road Distance (km)',2781,1533,2045],
'Get filtered column data with headers'
);
deepEqual(
tf.getVisibleColumnData(2),
[2781,1533,2045],
'Get visible column data'
);
deepEqual(
tf.getVisibleColumnData(2, true),
['Road Distance (km)',2781,1533,2045],
'Get visible column data with headers'
);
deepEqual(
tf.getFilteredColumnValues(2),
['2781','1533','2045'],
'Get filtered column data'
);
deepEqual(
tf.getFilteredColumnValues(2, true),
['Road Distance (km)','2781','1533','2045'],
'Get filtered column data with headers'
);
deepEqual(
tf.getVisibleColumnValues(2),
['2781','1533','2045'],
'Get visible column data'
);
deepEqual(
tf.getVisibleColumnValues(2, true),
['Road Distance (km)','2781','1533','2045'],
'Get visible column data with headers'
);
tf.clearFilters();
tf.filter();
});
@ -520,24 +652,24 @@ function colsVisibilityTests() { // issue 94
tf1.filter();
deepEqual(
tf1.getFilteredData(false, true),
tf1.getFilteredValues(false, true),
[
[6, ['Adelaide','3.1','38']],
[7, ['Adelaide','2','20.25']],
[8, ['Adelaide','2.15','40']]
],
'Get filtered table data with excluded columns'
'Get filtered table values with excluded columns'
);
deepEqual(
tf1.getFilteredData(true, true),
tf1.getFilteredValues(true, true),
[
[1, ['From','By Air (hrs)','By Rail (hrs)']],
[6, ['Adelaide','3.1','38']],
[7, ['Adelaide','2','20.25']],
[8, ['Adelaide','2.15','40']]
],
'Get filtered table data with headers and excluded columns'
'Get filtered table values with headers and excluded columns'
);
deepEqual(