Categories | Question details Back To List | ||
Sorting while maintaining filters I am using static smart rendering on my grid and I am trying to maintain/re-apply all current filters after sorting takes place. I have used custom code in the onAfterSorting event, and the logic is correct, but it seems to loop through the for loop too quickly to correctly re-apply the filters. I have come to this conclusion because if I insert an alert() in the code before the filterBy function call, it works just fine. Also, I have to use this.callEvent("onAfterSorting",[]); in the onBeforeSorting event to call the onAfterSorting event. My script doesn't seem to call the onAfterSorting event on its own. I am not sure if this has anything to do with it. Is there perhaps another way to maintain these filters when sorting using static smart rendering? Thanks again! subGridObj.attachEvent("onBeforeSorting",function(ind,type,direct){ this.clearAll(); // clear grid this.loadXML(subGridQString+(subGridQString.indexOf("?")>=0?"&":"?")+"orderby="+ind+"&direct="+direct+"&ManufId=100004"); //load a new dataset from the server, with necessary order this.setSortImgState(true,ind,direct); //set a correct sorting image // Calls the on after sorting even to apply all the filters after the sorting this.callEvent("onAfterSorting",[]); return false; }); // keep/reapply all current filters after applying a sort subGridObj.attachEvent("onAfterSorting",function(){ for( var i = 0; i < this.hdr.rows[2].cells.length; i++ ) { // If a filter does exist in the 2nd row of the header if( this.hdr.rows[2].cells[i].getElementsByTagName("INPUT")[0] ) { // if a value exists in the filter if(this.hdr.rows[2].cells[i].getElementsByTagName("INPUT")[0].value) { alert( 'filter: ' + i + ' by: ' + this.hdr.rows[2].cells[i].getElementsByTagName("INPUT")[0].value ); this.filterBy( i, this.hdr.rows[2].cells[i].getElementsByTagName("INPUT")[0].value, true ); } } } return true; }); Answer posted by Support on Nov 04, 2008 01:53 It can be done as this.loadXML(subGridQString+(subGridQString.indexOf("?")>=0?"&":"?")+"orderby="+ind+"&direct="+direct+"&ManufId=100004",function(){ subGridObj.filterByAll();//reapplly all filters created by shortcuts or makeFilter method }); |