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

Added Clear button

This commit is contained in:
Max Guglielmi 2015-02-19 15:40:46 +11:00
parent 31b7f18c9e
commit 0f64bb2f84
2 changed files with 61 additions and 58 deletions

2
dist/filtergrid.css vendored
View file

@ -1,6 +1,6 @@
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
- TableFilter stylesheet by Max Guglielmi - TableFilter stylesheet by Max Guglielmi
- (build date: Tue Feb 17 2015 22:16:34) - (build date: Thu Feb 19 2015 15:38:38)
- Edit below for your projects' needs - Edit below for your projects' needs
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/

View file

@ -620,7 +620,8 @@ function TableFilter(id) {
paging: null, paging: null,
checkList: null, checkList: null,
dropdown: null, dropdown: null,
popupFilter: null popupFilter: null,
clearButton: null
}; };
/*** TF events ***/ /*** TF events ***/
@ -831,9 +832,9 @@ function TableFilter(id) {
/*==================================================== /*====================================================
- clears filters - clears filters
=====================================================*/ =====================================================*/
_Clear: function() { // _Clear: function() {
o.ClearFilters(); // o.ClearFilters();
}, // },
/*==================================================== /*====================================================
- Help button onclick event - Help button onclick event
=====================================================*/ =====================================================*/
@ -1153,7 +1154,10 @@ TableFilter.prototype = {
this.Cpt.paging.init(); this.Cpt.paging.init();
} }
if(this.btnReset){ if(this.btnReset){
this.SetResetBtn(); // this.SetResetBtn();
var ClearButton = require('modules/clearButton').ClearButton;
this.Cpt.clearButton = new ClearButton(this);
this.Cpt.clearButton.init();
} }
if(this.helpInstructions){ if(this.helpInstructions){
this.SetHelpInstructions(); this.SetHelpInstructions();
@ -1453,7 +1457,8 @@ TableFilter.prototype = {
this.Cpt.rowsCounter.destroy(); this.Cpt.rowsCounter.destroy();
} }
if(this.btnReset){ if(this.btnReset){
this.RemoveResetBtn(); // this.RemoveResetBtn();
this.Cpt.clearButton.destroy();
} }
if(this.helpInstructions || !this.helpInstructions){ if(this.helpInstructions || !this.helpInstructions){
this.RemoveHelpInstructions(); this.RemoveHelpInstructions();
@ -2210,63 +2215,63 @@ TableFilter.prototype = {
/*==================================================== /*====================================================
- Generates reset button - Generates reset button
=====================================================*/ =====================================================*/
SetResetBtn: function(){ // SetResetBtn: function(){
if(!this.hasGrid && !this.isFirstLoad && this.btnResetEl){ // if(!this.hasGrid && !this.isFirstLoad && this.btnResetEl){
return; // return;
} // }
var f = this.fObj; // var f = this.fObj;
//id of container element // //id of container element
this.btnResetTgtId = f.btn_reset_target_id || null; // this.btnResetTgtId = f.btn_reset_target_id || null;
//reset button element // //reset button element
this.btnResetEl = null; // this.btnResetEl = null;
//defines reset text // //defines reset text
this.btnResetText = f.btn_reset_text || 'Reset'; // this.btnResetText = f.btn_reset_text || 'Reset';
//defines reset button tooltip // //defines reset button tooltip
this.btnResetTooltip = f.btn_reset_tooltip || 'Clear filters'; // this.btnResetTooltip = f.btn_reset_tooltip || 'Clear filters';
//defines reset button innerHtml // //defines reset button innerHtml
this.btnResetHtml = f.btn_reset_html || // this.btnResetHtml = f.btn_reset_html ||
(!this.enableIcons ? null : // (!this.enableIcons ? null :
'<input type="button" value="" class="'+this.btnResetCssClass+'" ' + // '<input type="button" value="" class="'+this.btnResetCssClass+'" ' +
'title="'+this.btnResetTooltip+'" />'); // 'title="'+this.btnResetTooltip+'" />');
var resetspan = dom.create('span', ['id',this.prfxResetSpan+this.id]); // var resetspan = dom.create('span', ['id',this.prfxResetSpan+this.id]);
// reset button is added to defined element // // reset button is added to defined element
if(!this.btnResetTgtId){ // if(!this.btnResetTgtId){
this.SetTopDiv(); // this.SetTopDiv();
} // }
var targetEl = !this.btnResetTgtId ? this.rDiv : // var targetEl = !this.btnResetTgtId ? this.rDiv :
dom.id( this.btnResetTgtId ); // dom.id( this.btnResetTgtId );
targetEl.appendChild(resetspan); // targetEl.appendChild(resetspan);
if(!this.btnResetHtml){ // if(!this.btnResetHtml){
var fltreset = dom.create('a', ['href', 'javascript:void(0);']); // var fltreset = dom.create('a', ['href', 'javascript:void(0);']);
fltreset.className = this.btnResetCssClass; // fltreset.className = this.btnResetCssClass;
fltreset.appendChild(dom.text(this.btnResetText)); // fltreset.appendChild(dom.text(this.btnResetText));
resetspan.appendChild(fltreset); // resetspan.appendChild(fltreset);
fltreset.onclick = this.Evt._Clear; // fltreset.onclick = this.Evt._Clear;
} else { // } else {
resetspan.innerHTML = this.btnResetHtml; // resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild; // var resetEl = resetspan.firstChild;
resetEl.onclick = this.Evt._Clear; // resetEl.onclick = this.Evt._Clear;
} // }
this.btnResetEl = dom.id(this.prfxResetSpan+this.id).firstChild; // this.btnResetEl = dom.id(this.prfxResetSpan+this.id).firstChild;
}, // },
/*==================================================== /*====================================================
- Removes reset button - Removes reset button
=====================================================*/ =====================================================*/
RemoveResetBtn: function(){ // RemoveResetBtn: function(){
if(!this.hasGrid || !this.btnResetEl){ // if(!this.hasGrid || !this.btnResetEl){
return; // return;
} // }
var resetspan = dom.id(this.prfxResetSpan+this.id); // var resetspan = dom.id(this.prfxResetSpan+this.id);
if(resetspan){ // if(resetspan){
resetspan.parentNode.removeChild( resetspan ); // resetspan.parentNode.removeChild( resetspan );
} // }
this.btnResetEl = null; // this.btnResetEl = null;
}, // },
/*==================================================== /*====================================================
- Generates status bar label - Generates status bar label
@ -2908,7 +2913,6 @@ TableFilter.prototype = {
this.isStartBgAlternate = false; this.isStartBgAlternate = false;
if(this.rememberGridValues){ if(this.rememberGridValues){
// this.RememberFiltersValue(this.fltsValuesCookie);
this.Cpt.store.saveFilterValues(this.fltsValuesCookie); this.Cpt.store.saveFilterValues(this.fltsValuesCookie);
} }
//applies filter props after filtering process //applies filter props after filtering process
@ -2917,7 +2921,6 @@ TableFilter.prototype = {
} else { } else {
this.startPagingRow = 0; this.startPagingRow = 0;
this.currentPageNb = 1; this.currentPageNb = 1;
//this.SetPagingInfo(this.validRowsIndex);
this.Cpt.paging.setPagingInfo(this.validRowsIndex); this.Cpt.paging.setPagingInfo(this.validRowsIndex);
}//starts paging process }//starts paging process
//invokes onafter callback //invokes onafter callback