1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 05:46:39 +02:00

Initial commit

This commit is contained in:
Max Guglielmi 2016-01-04 17:59:30 +11:00
parent ba7228cca1
commit 2a0ed49314
16 changed files with 181 additions and 118 deletions

4
dist/starter.html vendored
View file

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

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* 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.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* 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.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* MIT License
*/
table.TF{border-left:1px solid #ccc !important;border-top:none !important;border-right:none !important;border-bottom:none !important;}table.TF th{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;color:#333 !important}table.TF td{border-bottom:1px dotted #999 !important;padding:5px !important}.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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b !important;border-top:none !important;border-right:0 !important;border-bottom:none !important;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;color:#fff !important}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px !important}.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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.298Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.313Z
* 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}

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-03T02:53:59.235Z
* tablefilter v0.1.5 by Max Guglielmi
* build date: 2016-01-04T06:55:19.228Z
* MIT License
*/

View file

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

View file

@ -13,7 +13,7 @@ export class GridLayout extends Feature{
constructor(tf){
super(tf, 'gridLayout');
var f = this.config;
let f = this.config;
//defines grid width
this.gridWidth = f.grid_width || null;
@ -60,21 +60,26 @@ export class GridLayout extends Feature{
* Generates a grid with fixed headers
*/
init(){
var tf = this.tf;
var f = this.config;
var tbl = tf.tbl;
let tf = this.tf;
let f = this.config;
let tbl = tf.tbl;
if(this.initialized){
return;
}
// Override reference rows indexes
tf.refRow = Types.isNull(tf.startRow) ? 0 : tf.startRow;
tf.headersRow = 0;
tf.filtersRowIndex = 1;
tf.isExternalFlt = true;
// default width of 100px if column widths not set
if(!tf.hasColWidths){
tf.colWidths = [];
for(var k=0; k<tf.nbCells; k++){
var colW,
for(let k=0; k<tf.nbCells; k++){
let colW,
cell = tbl.rows[this.gridHeadRowIndex].cells[k];
if(cell.width !== ''){
colW = cell.width;
@ -89,7 +94,7 @@ export class GridLayout extends Feature{
}
tf.setColWidths(this.gridHeadRowIndex);
var tblW;//initial table width
let tblW;//initial table width
if(tbl.width !== ''){
tblW = tbl.width;
}
@ -122,7 +127,7 @@ export class GridLayout extends Feature{
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
var t = Dom.remove(tbl);
let t = Dom.remove(tbl);
this.tblCont.appendChild(t);
//In case table width is expressed in %
@ -131,7 +136,7 @@ export class GridLayout extends Feature{
tbl.clientWidth : tblW) + 'px';
}
var d = Dom.remove(this.tblCont);
let d = Dom.remove(this.tblCont);
this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table
@ -148,15 +153,15 @@ export class GridLayout extends Feature{
//Headers table
this.headTbl = Dom.create('table', ['id', this.prfxHeadTbl + tf.id]);
var tH = Dom.create('tHead');
let tH = Dom.create('tHead');
//1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature
var hRow = tbl.rows[this.gridHeadRowIndex];
var sortTriggers = [];
for(var n=0; n<tf.nbCells; n++){
var c = hRow.cells[n];
var thId = c.getAttribute('id');
let hRow = tbl.rows[this.gridHeadRowIndex];
let sortTriggers = [];
for(let n=0; n<tf.nbCells; n++){
let c = hRow.cells[n];
let thId = c.getAttribute('id');
if(!thId || thId===''){
thId = this.prfxGridTh+n+'_'+tf.id;
c.setAttribute('id', thId);
@ -165,24 +170,24 @@ export class GridLayout extends Feature{
}
//Filters row is created
var filtersRow = Dom.create('tr');
let filtersRow = Dom.create('tr');
if(this.gridEnableFilters && tf.fltGrid){
tf.externalFltTgtIds = [];
for(var j=0; j<tf.nbCells; j++){
var fltTdId = tf.prfxFlt+j+ this.prfxGridFltTd +tf.id;
var cl = Dom.create(tf.fltCellTag, ['id', fltTdId]);
for(let j=0; j<tf.nbCells; j++){
let fltTdId = tf.prfxFlt+j+ this.prfxGridFltTd +tf.id;
let cl = Dom.create(tf.fltCellTag, ['id', fltTdId]);
filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId;
}
}
//Headers row are moved from content table to headers table
for(var i=0; i<this.gridHeadRows.length; i++){
var headRow = tbl.rows[this.gridHeadRows[0]];
for(let i=0; i<this.gridHeadRows.length; i++){
let headRow = tbl.rows[this.gridHeadRows[0]];
tH.appendChild(headRow);
}
this.headTbl.appendChild(tH);
if(tf.filtersRowIndex === 0){
tH.insertBefore(filtersRow,hRow);
tH.insertBefore(filtersRow, hRow);
} else {
tH.appendChild(filtersRow);
}
@ -191,7 +196,7 @@ export class GridLayout extends Feature{
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
//THead needs to be removed in content table for sort feature
var thead = Dom.tag(tbl, 'thead');
let thead = Dom.tag(tbl, 'thead');
if(thead.length>0){
tbl.removeChild(thead[0]);
}
@ -216,15 +221,15 @@ export class GridLayout extends Feature{
//scroll synchronisation
Event.add(this.tblCont, 'scroll', (evt)=> {
var elm = Event.target(evt);
var scrollLeft = elm.scrollLeft;
let elm = Event.target(evt);
let scrollLeft = elm.scrollLeft;
this.headTblCont.scrollLeft = scrollLeft;
//New pointerX calc taking into account scrollLeft
// if(!o.isPointerXOverwritten){
// try{
// o.Evt.pointerX = function(evt){
// var e = evt || global.event;
// var bdScrollLeft = tf_StandardBody().scrollLeft +
// let e = evt || global.event;
// let bdScrollLeft = tf_StandardBody().scrollLeft +
// scrollLeft;
// return (e.pageX + scrollLeft) ||
// (e.clientX + bdScrollLeft);
@ -237,7 +242,7 @@ export class GridLayout extends Feature{
});
//Configure sort extension if any
var sort = (f.extensions || []).filter(function(itm){
let sort = (f.extensions || []).filter(function(itm){
return itm.name === 'sort';
});
if(sort.length === 1){
@ -250,9 +255,9 @@ export class GridLayout extends Feature{
//Col elements are enough to keep column widths after sorting and
//filtering
var createColTags = function(){
for(var k=(tf.nbCells-1); k>=0; k--){
var col = Dom.create('col', ['id', tf.id+'_col_'+k]);
let createColTags = function(){
for(let k=(tf.nbCells-1); k>=0; k--){
let col = Dom.create('col', ['id', tf.id+'_col_'+k]);
tbl.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidths[k];
this.gridColElms[k] = col;
@ -263,26 +268,26 @@ export class GridLayout extends Feature{
if(!this.tblHasColTag){
createColTags.call(this);
} else {
var cols = Dom.tag(tbl, 'col');
for(var ii=0; ii<tf.nbCells; ii++){
let cols = Dom.tag(tbl, 'col');
for(let ii=0; ii<tf.nbCells; ii++){
cols[ii].setAttribute('id', tf.id+'_col_'+ii);
cols[ii].style.width = tf.colWidths[ii];
this.gridColElms.push(cols[ii]);
}
}
var afterColResizedFn = Types.isFn(f.on_after_col_resized) ?
let afterColResizedFn = Types.isFn(f.on_after_col_resized) ?
f.on_after_col_resized : null;
f.on_after_col_resized = function(o, colIndex){
if(!colIndex){
return;
}
var w = o.crWColsRow.cells[colIndex].style.width;
var col = o.gridColElms[colIndex];
let w = o.crWColsRow.cells[colIndex].style.width;
let col = o.gridColElms[colIndex];
col.style.width = w;
var thCW = o.crWColsRow.cells[colIndex].clientWidth;
var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
let thCW = o.crWColsRow.cells[colIndex].clientWidth;
let tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
if(thCW != tdCW){
o.headTbl.style.width = tbl.clientWidth+'px';
@ -308,13 +313,13 @@ export class GridLayout extends Feature{
* Removes the grid layout
*/
destroy(){
var tf = this.tf;
var tbl = tf.tbl;
let tf = this.tf;
let tbl = tf.tbl;
if(!this.initialized){
return;
}
var t = Dom.remove(tbl);
let t = Dom.remove(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
Dom.remove(this.tblMainCont);

View file

@ -84,6 +84,12 @@ export class PopupFilter extends Feature{
}
var tf = this.tf;
// Override headers row index if no grouped headers
if(tf.headersRow <= 1){
tf.headersRow = 0;
}
for(var i=0; i<tf.nbCells; i++){
if(tf.getFilterType(i) === tf.fltTypeNone){
continue;
@ -106,6 +112,7 @@ export class PopupFilter extends Feature{
this.emitter.on(['after-filtering'], ()=> this.closeAll());
this.emitter.on(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.emitter.on(['filters-row-inserted'], ()=> this.tf.headersRow++);
this.initialized = true;
}
@ -257,6 +264,7 @@ export class PopupFilter extends Feature{
this.emitter.off(['after-filtering'], ()=> this.closeAll());
this.emitter.off(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.emitter.off(['filters-row-inserted'], ()=> this.tf.headersRow++);
this.initialized = false;
}

View file

@ -109,14 +109,14 @@ export class TableFilter {
this.headersRow = isNaN(f.headers_row_index) ?
(this.filtersRowIndex === 0 ? 1 : 0) : f.headers_row_index;
if(this.gridLayout){
if(this.headersRow > 1){
this.filtersRowIndex = this.headersRow+1;
} else {
this.filtersRowIndex = 1;
this.headersRow = 0;
}
}
// if(this.gridLayout){
// if(this.headersRow > 1){
// this.filtersRowIndex = this.headersRow+1;
// } else {
// this.filtersRowIndex = 1;
// this.headersRow = 0;
// }
// }
//defines tag of the cells containing filters (td/th)
this.fltCellTag = f.filters_cell_tag!=='th' ||
@ -568,14 +568,14 @@ export class TableFilter {
if(!this.tbl){
this.tbl = Dom.id(this.id);
}
if(this.gridLayout){
this.refRow = this.startRow===null ? 0 : this.startRow;
}
if(this.popupFilters &&
((this.filtersRowIndex === 0 && this.headersRow === 1) ||
this.gridLayout)){
this.headersRow = 0;
}
// if(this.gridLayout){
// this.refRow = this.startRow===null ? 0 : this.startRow;
// }
// if(this.popupFilters &&
// ((this.filtersRowIndex === 0 && this.headersRow === 1) ||
// this.gridLayout)){
// this.headersRow = 0;
// }
let Mod = this.Mod;
let n = this.singleSearchFlt ? 1 : this.nbCells,
@ -619,39 +619,33 @@ export class TableFilter {
//filters grid is not generated
if(!this.fltGrid){
this.refRow = this.refRow-1;
if(this.gridLayout){
this.refRow = 0;
}
this.nbFilterableRows = this.getRowsNb();
this.nbVisibleRows = this.nbFilterableRows;
this.nbRows = this.nbFilterableRows + this.refRow;
this._initNoFilters();
} else {
if(this.isFirstLoad){
let fltrow;
if(!this.gridLayout){
let thead = Dom.tag(this.tbl, 'thead');
if(thead.length > 0){
fltrow = thead[0].insertRow(this.filtersRowIndex);
} else {
fltrow = this.tbl.insertRow(this.filtersRowIndex);
}
let fltrow = this._insertFiltersRow();
// if(!this.gridLayout){
// let thead = Dom.tag(this.tbl, 'thead');
// if(thead.length > 0){
// fltrow = thead[0].insertRow(this.filtersRowIndex);
// } else {
// fltrow = this.tbl.insertRow(this.filtersRowIndex);
// }
if(this.headersRow > 1 &&
this.filtersRowIndex <= this.headersRow &&
!this.popupFilters){
this.headersRow++;
}
if(this.popupFilters){
this.headersRow++;
}
// if(this.headersRow > 1 &&
// this.filtersRowIndex <= this.headersRow &&
// !this.popupFilters){
// this.headersRow++;
// }
// if(this.popupFilters){
// this.headersRow++;
// }
fltrow.className = this.fltsRowCssClass;
// fltrow.className = this.fltsRowCssClass;
if(this.isExternalFlt || this.popupFilters){
fltrow.style.display = 'none';
}
}
// if(this.isExternalFlt || this.popupFilters){
// fltrow.style.display = 'none';
// }
// }
this.nbFilterableRows = this.getRowsNb();
this.nbVisibleRows = this.nbFilterableRows;
@ -909,6 +903,48 @@ export class TableFilter {
this.emitter.emit('initialized', this);
}
_insertFiltersRow() {
if(this.gridLayout){
return;
}
let fltrow;
let thead = Dom.tag(this.tbl, 'thead');
if(thead.length > 0){
fltrow = thead[0].insertRow(this.filtersRowIndex);
} else {
fltrow = this.tbl.insertRow(this.filtersRowIndex);
}
if(this.headersRow > 1 && this.filtersRowIndex <= this.headersRow /*&&
!this.popupFilters*/){
this.headersRow++;
}
fltrow.className = this.fltsRowCssClass;
if(this.isExternalFlt){
fltrow.style.display = 'none';
}
this.emitter.emit('filters-row-inserted', this, fltrow);
return fltrow;
}
_initNoFilters(){
if(this.fltGrid){
return;
}
this.refRow = this.refRow > 0 ? this.refRow-1 : 0;
// if(this.gridLayout){
// this.refRow = 0;
// }
this.nbFilterableRows = this.getRowsNb();
this.nbVisibleRows = this.nbFilterableRows;
this.nbRows = this.nbFilterableRows + this.refRow;
}
/**
* Return a feature instance for a given name
* @param {String} name Name of the feature

View file

@ -1,8 +1,7 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
grid_layout: true,
sort: false
grid_layout: true
});
tf.init();
@ -14,6 +13,10 @@ test('GridLayout component', function() {
notEqual(gridLayout.tblCont, null, 'GridLayout main HTML table container element');
notEqual(gridLayout.headTblCont, null, 'GridLayout headers container element');
notEqual(gridLayout.headTbl, null, 'GridLayout headers HTML table');
deepEqual(tf.startRow, null, 'Optional startRow row index');
deepEqual(tf.refRow, 0, 'Reference row index');
deepEqual(tf.headersRow, 0, 'Headers row index');
deepEqual(tf.filtersRowIndex, 1, 'Filters row index');
});
test('Destroy GridLayout component', function() {

View file

@ -11,6 +11,7 @@
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFilterElement(0), null,
'No filter element for column 0');
deepEqual(tf.refRow, 1, 'Reference row index');
});
test('Paging with no filters', function() {
@ -25,6 +26,7 @@
tf.init();
deepEqual(tf.getFilterElement(4), null,
'No filter element for column 4');
deepEqual(tf.refRow, 1, 'Reference row index');
});
test('Grid layout with no filters', function() {
@ -39,6 +41,13 @@
tf.init();
deepEqual(tf.getFilterElement(2), null,
'No filter element for column 2');
deepEqual(tf.refRow, 0, 'Reference row index');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
});
})(window, TableFilter);

View file

@ -16,6 +16,7 @@ test('Pop-up filter component', function() {
notEqual(popupFilter, null, 'PopupFilter instanciated');
deepEqual(popupFilter.popUpFltElms instanceof Array,
true, 'Type of popUpFltElms property');
deepEqual(tf.headersRow, 1, 'Headers row index');
});
module('UI elements');
@ -91,6 +92,7 @@ test('Re-instantiated with grid-layout', function() {
notEqual(popupFilter, null, 'PopupFilter instanciated');
deepEqual(popupFilter.popUpFltElms instanceof Array,
true, 'Type of popUpFltElms property');
deepEqual(tf.headersRow, 0, 'Headers row index');
});
test('Pop-up filter UI elements with grid-layout', function() {
@ -158,11 +160,11 @@ test('Properties', function() {
'function', 'Feature enable method');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.destroy();
var fltIcn1 = popupFilter.popUpFltImgs[3];
deepEqual(fltIcn1, undefined, 'Filter icon is removed');
deepEqual(id(tf.fltIds[3]), null, 'Filter is removed');
deepEqual(tf.hasGrid(), false, 'Filters removed');
});
// module('Tear-down');
// test('TableFilter removed', function() {
// tf.destroy();
// var fltIcn1 = popupFilter.popUpFltImgs[3];
// deepEqual(fltIcn1, undefined, 'Filter icon is removed');
// deepEqual(id(tf.fltIds[3]), null, 'Filter is removed');
// deepEqual(tf.hasGrid(), false, 'Filters removed');
// });