SpreadJS Documentation > Sample Code > Sample Code for Row Filtering > Getting the Row Filter Results |
You can get information about the row filter results.
This example gets row filter results.
JavaScript |
Copy Code
|
---|---|
$(document).ready(function () { var spread = new GcSpread.Sheets.Spread($("#ss").get(0),{sheetCount:3}); var activeSheet = spread.getActiveSheet(); activeSheet.setRowCount(7); activeSheet.setValue(0, 0, "North"); activeSheet.setValue(1, 0, "South"); activeSheet.setValue(2, 0, "East"); activeSheet.setValue(3, 0, "South"); activeSheet.setValue(4, 0, "North"); activeSheet.setValue(5, 0, "North"); activeSheet.setValue(6, 0, "West"); activeSheet.setColumnWidth(0, 80); //Set a rowFilter. activeSheet.rowFilter(new GcSpread.Sheets.HideRowFilter(new GcSpread.Sheets.Range(0, 0, 7, 1))); $("#button1").click(function(){ var rowFilter = $("#ss").data("spread").getActiveSheet().rowFilter(); //********************************************* //Exit if Column1 has not been filtered. //********************************************* if(!rowFilter.isColumnFiltered(0)){ return; } //********************************************* //Filtered strings //********************************************* var filterItems = rowFilter.getFilterItems(0); var str = "Filtered strings:"; for(var i=0;i if(i>0){ str += ","; } str += " " + filterItems[i].expected; } console.log(str); console.log(""); //********************************************* //Number of Filtered-In (displayed) rows //********************************************* console.log("Number of Filtered-In (displayed) rows: " + rowFilter.filterInRows.length); console.log(""); //********************************************* //Number of Filtered-Out (hidden) rows //********************************************* console.log("Number of Filtered-Out (hidden) rows: " + (rowFilter.range.rowCount - rowFilter.filterInRows.length)); console.log(""); for(var i = rowFilter.range.row; i < rowFilter.range.rowCount; i++){ //********************************************* //Filtered-Out (hidden) row index //********************************************* if(rowFilter.isRowFilteredOut(i)){ console.log("Filtered-Out (hidden) row index: " + i); } } console.log(""); //********************************************* //Filtered-In (displayed)/Filtered-Out (hidden) rows //********************************************* for(var i = rowFilter.range.row; i < rowFilter.range.rowCount; i++){ if(rowFilter.isRowFilteredOut(i)){ console.log("Data of Filtered-Out (hidden) row: " + activeSheet.getValue(i, 0)); }else{ console.log("Data of Filtered-In (displayed) row: " + activeSheet.getValue(i, 0)); } } }); }); |