Class Filter

Filter

Access and modify existing filters. To create a new filter, use Range.createFilter().

Methods

MethodReturn typeBrief description
getColumnFilterCriteria(columnPosition)FilterCriteriaGets the filter criteria on the specified column, or null if no filter criteria is set.
getRange()RangeGets the range this filter is applied to.
remove()voidRemoves this filter.
removeColumnFilterCriteria(columnPosition)FilterRemoves the filter criteria from the specified column.
setColumnFilterCriteria(columnPosition, filterCriteria)FilterSets the filter criteria on the specified column.
sort(columnPosition, ascending)FilterSorts the filtered range by the specified column, excluding the first row (the header row) in the range this filter is applied to.

Detailed documentation

getColumnFilterCriteria(columnPosition)

Gets the filter criteria on the specified column, or null if no filter criteria is set.

Parameters

NameTypeDescription
columnPositionIntegerThe 1-indexed position of the column.

Return

FilterCriteria — the filter criteria


getRange()

Gets the range this filter is applied to.

Return

Range — the range


remove()

Removes this filter.


removeColumnFilterCriteria(columnPosition)

Removes the filter criteria from the specified column.

Parameters

NameTypeDescription
columnPositionIntegerThe 1-indexed position of the column.

Return

Filter — the filter, for chaining


setColumnFilterCriteria(columnPosition, filterCriteria)

Sets the filter criteria on the specified column.

Parameters

NameTypeDescription
columnPositionIntegerThe 1-indexed position of the column.
filterCriteriaFilterCriteriaThe filter criteria to set. If null, remove filter criteria from the specified column; alternatively, use removeColumnFilterCriteria(columnPosition).

Return

Filter — the filter, for chaining


sort(columnPosition, ascending)

Sorts the filtered range by the specified column, excluding the first row (the header row) in the range this filter is applied to.

Parameters

NameTypeDescription
columnPositionIntegerThe 1-indexed position of the column.
ascendingBooleanIf true, sort the filtered range in ascending order; if false, sort the filtered range in descending order.

Return

Filter — the filter, for chaining

Send feedback about...

Apps Script
Apps Script
Need help? Visit our support page.