1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-11 19:06:50 +02:00

Merge pull request #17 from koalyptus/fix-search-paging

Fixed search yielding no matches under paging
This commit is contained in:
koalyptus 2015-07-15 23:37:08 +10:00
commit fabff99316
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
* build date: 2015-07-14T13:48:08.344Z
* build date: 2015-07-15T13:30:52.392Z
* MIT License
*/

View file

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

View file

@ -63,10 +63,10 @@ test('Set page', function() {
'Expected page number in paging drop-down selector');
});
test('Set page via drop-down page selector', function() {
paging.pagingSlc.selectedIndex = 2;
deepEqual(paging.getPage(), 3, 'Expected page number');
paging.pagingSlc.selectedIndex = 3;
paging.changePage(paging.pagingSlc.selectedIndex);
deepEqual(paging.getPage(), 4, 'Expected page number');
});
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');
});
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() {
tf.clearFilters();
paging.resultsPerPageSlc.options[1].selected = true;
@ -126,6 +133,12 @@ test('Set page', function() {
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() {
tf.setFilterValue(1, 'Perth');
tf.filter();
@ -135,7 +148,15 @@ test('Filter from non starting page', function() {
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() {
tf.clearFilters();
paging.resultsPerPageSlc.options[1].selected = true;
paging.changeResultsPerPage();
deepEqual(paging.pagingLength, 4, 'Expected page length');