show/hide Filtering Grid Header on demand

Hi,
I’m using a Pro v3.6 of DHTMLX, having issues with Filtering through Grid Header

  • I’m using a two state toolbar button to show/hide the header , following forum posts i’ve solved the issue [reset filters] when the header is removed
    but my next problem is that the header filters only work for the first time the header is shown , all subsequent add/create results in a nonfunctional filtering fields

any comments/suggestions will be much appreciated

below is the button event handler code :

[code] case “cppp_filter”:
if(state){ ProcessGrid.attachHeader("#text_filter,#text_filter,#select_filter,#select_filter,#text_filter,#numeric_filter");
ProcessGrid.setSizes();
}
else {
var nCols = ProcessGrid.getColumnsNum();
for(i=1 ; i<nCols ; i++){
ProcessGrid.getFilterElement(i).value = “”;
ProcessGrid.filterBy(i,"");
}
ProcessGrid._f_rowsBuffer = null;
ProcessGrid.filterByAll();

                        try{ ProcessGrid.detachHeader(1); }catch(err){};
                    }
                    break;[/code]

Grid Loading Code :

[code] ProcessGrid.clearAll();
ProcessGrid.load("/php/EnumProcess.php?ProjID="+ProjID, function(){
var nCols = ProcessGrid.getColumnsNum();
for(i=1 ; i<nCols ; i++){
ProcessGrid.getFilterElement(i).value = “”;
ProcessGrid.filterBy(i,"");
}
ProcessGrid._f_rowsBuffer = null;
ProcessGrid.filterByAll();
ProcessGrid.refreshFilters();
if(MainToolBar.getItemState(“cppp_filter”)){
try{ ProcessGrid.detachHeader(1); }catch(err){};

ProcessGrid.attachHeader("#text_filter,#text_filter,#select_filter,#select_filter,#text_filter,#numeric_filter");
ProcessGrid.setSizes();
}
}, “js” );[/code]

Regards,
MOTASH

Hi ,

i found that the problem happens because the Grid.filters array don’t get cleared , so the next time a new set of elements are added , and wrong behavior happens with indexes

The solution i found is :
1- Clear Filter inputs and reset Grid to no filtering state

var nCols = Grid.getColumnsNum(); for(i=1 ; i<nCols ; i++){ try{Grid.getFilterElement(i).value = "";}catch(err){}; Grid.filterBy(i,""); } Grid._f_rowsBuffer = null; Grid.filterByAll();

2- detach header / clear filters array

Grid.detachHeader(1); Grid.filters = [] ;