1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-23 16:52:26 +02:00

Fixed search yielding no matches under paging

This commit is contained in:
Max Guglielmi 2015-07-15 23:34:19 +10:00
parent 4784b3fbde
commit 1ea547e19b
4 changed files with 33 additions and 18 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/** /**
* TableFilter v0.0.0 by Max Guglielmi * TableFilter v0.0.0 by Max Guglielmi
* build date: 2015-07-14T13:48:08.344Z * build date: 2015-07-15T13:30:52.392Z
* MIT License * MIT License
*/ */

View file

@ -375,7 +375,7 @@ export class Paging{
} }
var isRowValid = row.getAttribute('validRow'); var isRowValid = row.getAttribute('validRow');
if(Types.isNull(isRowValid) || Boolean(isRowValid)){ if(Types.isNull(isRowValid) || Boolean(isRowValid==='true')){
tf.validRowsIndex.push(j); tf.validRowsIndex.push(j);
} }
} }
@ -394,13 +394,8 @@ export class Paging{
mdiv.style.visibility = 'visible'; mdiv.style.visibility = 'visible';
if(this.pageSelectorType === tf.fltTypeSlc){ if(this.pageSelectorType === tf.fltTypeSlc){
for(var z=0; z<this.nbPages; z++){ for(var z=0; z<this.nbPages; z++){
var currOpt = new Option( var opt = Dom.createOpt(z+1, z*this.pagingLength, false);
(z+1), this.pagingSlc.options[z] = opt;
z*this.pagingLength,
false,
false
);
this.pagingSlc.options[z] = currOpt;
} }
} else{ } else{
//input type //input type
@ -437,9 +432,7 @@ export class Paging{
var isRowValid = r.getAttribute('validRow'); var isRowValid = r.getAttribute('validRow');
if(h>=this.startPagingRow && h<endPagingRow){ if(h>=this.startPagingRow && h<endPagingRow){
// if(r.getAttribute('validRow')==='true' || if(Types.isNull(isRowValid) || Boolean(isRowValid==='true')){
// !r.getAttribute('validRow')){
if(Types.isNull(isRowValid) || Boolean(isRowValid)){
r.style.display = ''; r.style.display = '';
} }
if(tf.alternateBgs && alternateRows){ if(tf.alternateBgs && alternateRows){

View file

@ -63,10 +63,10 @@ test('Set page', function() {
'Expected page number in paging drop-down selector'); 'Expected page number in paging drop-down selector');
}); });
test('Set page via drop-down page selector', function() { test('Set page via drop-down page selector', function() {
paging.pagingSlc.selectedIndex = 2; paging.pagingSlc.selectedIndex = 3;
deepEqual(paging.getPage(), 3, 'Expected page number'); paging.changePage(paging.pagingSlc.selectedIndex);
deepEqual(paging.getPage(), 4, 'Expected page number');
}); });
test('Filter from non starting page', function() { test('Filter from non starting page', function() {
@ -78,6 +78,13 @@ test('Filter from non starting page', function() {
1, 'Expected visible rows after page change'); 1, 'Expected visible rows after page change');
}); });
test('Filter with dummy value', function() {
tf.clearFilters();
tf.setFilterValue(0, 'dfsdf');
tf.filter();
deepEqual(tf.validRowsIndex.length, 0, 'Expected valid rows');
});
test('Set results per page', function() { test('Set results per page', function() {
tf.clearFilters(); tf.clearFilters();
paging.resultsPerPageSlc.options[1].selected = true; paging.resultsPerPageSlc.options[1].selected = true;
@ -126,6 +133,12 @@ test('Set page', function() {
deepEqual(paging.getPage(), 3, 'Expected page number'); deepEqual(paging.getPage(), 3, 'Expected page number');
}); });
test('Set page via drop-down page selector', function() {
paging.pagingSlc.selectedIndex = 3;
paging.changePage(paging.pagingSlc.selectedIndex);
deepEqual(paging.getPage(), 4, 'Expected page number');
});
test('Filter from non starting page', function() { test('Filter from non starting page', function() {
tf.setFilterValue(1, 'Perth'); tf.setFilterValue(1, 'Perth');
tf.filter(); tf.filter();
@ -135,7 +148,15 @@ test('Filter from non starting page', function() {
1, 'Expected visible rows after page change'); 1, 'Expected visible rows after page change');
}); });
test('Filter with dummy value', function() {
tf.clearFilters();
tf.setFilterValue(0, 'dfsdf');
tf.filter();
deepEqual(tf.validRowsIndex.length, 0, 'Expected valid rows');
});
test('Set results per page', function() { test('Set results per page', function() {
tf.clearFilters();
paging.resultsPerPageSlc.options[1].selected = true; paging.resultsPerPageSlc.options[1].selected = true;
paging.changeResultsPerPage(); paging.changeResultsPerPage();
deepEqual(paging.pagingLength, 4, 'Expected page length'); deepEqual(paging.pagingLength, 4, 'Expected page length');