filter
Enables/disables or sets the filter for a given range.
Parameters
filter Boolean | Object | Array
Determines the action performed by the method.
- Passing
true
enables the filtering for the given range. - Passing
false
disables and clears the set filters. - Passing a
{ column: Number, filter: kendo.spreadsheet.Filter }
object applies the filter to the respective column. - Passing an array of
{ column: Number, filter: kendo.spreadsheet.Filter }
objects applies each filter to the respective column. The column index is relative to the beginning of the range.
Example - enable filter
<div id="spreadsheet"></div>
<script type="text/javascript" charset="utf-8">
$("#spreadsheet").kendoSpreadsheet();
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();
var values = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
sheet.range("A1:C3").values(values);
sheet.range("A1:C3").filter(true);
</script>
Example - disable filter```
<div id="spreadsheet"></div>
<script type="text/javascript" charset="utf-8">
$("#spreadsheet").kendoSpreadsheet();
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();
var values = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
sheet.range("A1:C3").values(values);
sheet.range("A1:C3").filter(true);
sheet.range("A1:C3").filter(false);
</script>
#### Example - set filter```
<div id="spreadsheet"></div>
<script type="text/javascript" charset="utf-8">
$("#spreadsheet").kendoSpreadsheet();
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();
var values = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
var values = [
[ "C 1", "C 2", "C 3" ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
sheet.range("A1:C3").values(values);
var filter = new kendo.spreadsheet.ValueFilter({ values: [ 7 ] });
sheet.range("A1:C3").filter({ column: 0, filter: filter });
</script>
Example - set multiple filters
<div id="spreadsheet"></div>
<script type="text/javascript" charset="utf-8">
$("#spreadsheet").kendoSpreadsheet();
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();
var values = [
[ "C 1", "C 2", "C 3" ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
sheet.range("A1:C3").values(values);
var filter = new kendo.spreadsheet.ValueFilter({ values: [ 7 ] });
var filter2 = new kendo.spreadsheet.ValueFilter({ values: [ 8 ] });
sheet.range("A1:C3").filter([
{ column: 0, filter: filter },
{ column: 1, filter: filter2 }
]);
</script>