SpreadJS Documentation > Sample Code > Sample Code for Row Filtering > Filtering a Row with Code |
You can filter a row using code.
This example filters a row with code.
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 row Filter. activeSheet.rowFilter(new GcSpread.Sheets.HideRowFilter(new GcSpread.Sheets.Range(0, 0, 7, 1))); $("#button1").click(function(){ //Filter Column1 by "North". var rowFilter = $("#ss").data("spread").getActiveSheet().rowFilter(); rowFilter.addTextFilter(0, GcSpread.Sheets.ComparisonOperator.EqualsTo, "North"); rowFilter.filter(0); }); $("#button2").click(function(){ // Remove filtering of Column1 var rowFilter = $("#ss").data("spread").getActiveSheet().rowFilter(); if(rowFilter){ rowFilter.removeFilterItems(0); rowFilter.reFilter(); } }); }); |