[]
RowFilterBase
• new RowFilterBase(range
)
Represents a row filter base that supports row filters for filtering rows in a sheet.
Name | Type | Description |
---|---|---|
range |
Range |
The filter range. |
• extendedRange: Range
Represents the extendedRange for the row filter.
• range: Range
Represents the range for the row filter.
• typeName: string
Represents the type name string used for supporting serialization.
▸ addFilterItem(col
, condition
): void
Adds a specified filter to the row filter.
example
sheet.setRowCount(3);
sheet.setColumnCount(1);
sheet.setArray(0, 0,
[
[ 1 ],
[ 2 ],
[ 3 ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,expected: '3'});
sheet.rowFilter().addFilterItem(0, condition);
sheet.rowFilter().filter(0);
Name | Type | Description |
---|---|---|
col |
number |
The column index. |
condition |
Condition | Condition [] |
The condition to filter. |
void
▸ filter(col?
): void
Filters the specified column.
example
sheet.setRowCount(2);
sheet.setColumnCount(1);
sheet.setArray(0, 0,
[
[ "a" ],
[ "b" ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,expected: 'a'});
var rowFilter = sheet.rowFilter();
rowFilter.addFilterItem(0, condition);
rowFilter.filter(0);
Name | Type | Description |
---|---|---|
col? |
number |
The index of the column to be filtered; if it is omitted, all the columns in the range will be filtered. |
void
▸ filterButtonVisible(col?
, value?
): any
Gets or sets whether the sheet column's filter button is displayed.
example
sheet.setArray(2, 2,
[
[ 1, 4 ],
[ 2, 5 ],
[ 3, 6 ]
] );
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(2, 2, 3, 2)));
console.log(sheet.rowFilter().filterButtonVisible()); // true
sheet.rowFilter().filterButtonVisible(2, false);
console.log(sheet.rowFilter().filterButtonVisible(2)); // false
console.log(sheet.rowFilter().filterButtonVisible(3)); // true
Name | Type |
---|---|
col? |
number | boolean |
value? |
boolean |
any
No parameter `false` if all filter buttons are invisible; otherwise, `true`.
One parameter col `false` if the specified column filter button is invisible; otherwise, `true`.
One parameter value <c>GC.Spread.Sheets.Filter.RowFilterBase</c> sets all filter buttons to be visible(true)/invisible(false).
Two parameters col,value <c>GC.Spread.Sheets.Filter.RowFilterBase</c> sets the specified column filter button to be visible(true)/invisible(false).
▸ fromJSON(settings
): void
Loads the object state from the specified JSON string.
Name | Type | Description |
---|---|---|
settings |
Object |
The row filter data from deserialization. |
void
▸ getFilterItems(col
): Condition
[]
Gets the filters for the specified column.
example
sheet.getCell(0, 0).value("a");
sheet.getCell(0, 1).value("b");
sheet.getCell(1, 0).value("ac");
sheet.getCell(1, 1).value("bd");
sheet.rowFilter( new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range( -1, -1, -1, -1)));
var condition1 = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,expected: 'a' });
var condition2 = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,beginsWith: '' });
sheet.rowFilter().addFilterItem(0, condition1);
sheet.rowFilter().addFilterItem(1, condition2);
console.log(sheet.rowFilter().getFilterItems(0)); // result is array, length is 1, and the item equals to condition1.
Name | Type | Description |
---|---|---|
col |
number |
The column index. |
Returns a collection that contains conditions that belong to a specified column.
▸ getFilteredItems(): Condition
[]
Gets all the filtered conditions.
example
sheet.setRowCount(3);
sheet.setColumnCount(2);
sheet.setArray(0, 0,
[
[ 1, 2 ],
[ 3, 4 ],
[ 5, 6 ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan, expected: 1 });
var condition1 = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan, expected: 4 });
sheet.rowFilter().addFilterItem(0, condition);
sheet.rowFilter().addFilterItem(1, condition1);
console.log(sheet.rowFilter().getFilteredItems().length); // 0
sheet.rowFilter().filter();
console.log(sheet.rowFilter().getFilteredItems().length); // 2
sheet.rowFilter().removeFilterItems(0);
console.log(sheet.rowFilter().getFilteredItems().length); // 1
sheet.rowFilter().removeFilterItems(1);
console.log(sheet.rowFilter().getFilteredItems().length); // 0
Returns a collection that contains all the filtered conditions.
▸ getSortState(col
): SortState
Gets the current sort state.
example
sheet.setArray(0, 0, [
[ 4 ],
[ 3 ],
[ 2 ],
[ 1 ],
[ 0 ]
]);
sheet.rowFilter( new GC.Spread.Sheets.Filter.HideRowFilter( new GC.Spread.Sheets.Range( 0, 0, 5, 1 ) ) );
sheet.rowFilter().addFilterItem( 0, new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan, expected: 2 }));
sheet.rowFilter().filter(0);
sheet.rowFilter().sortColumn(0, false);
console.log(sheet.rowFilter().getSortState(0)); // 2
Name | Type | Description |
---|---|---|
col |
number |
The column index. |
The sort state of the current filter.
▸ isFiltered(col?
): boolean
Gets a value that indicates whether any row or specified column is filtered.
example
//This example uses the isFiltered method.
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 GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, 7, 1)));
//button
$("#button1").click(function () {
var rowFilter = spread.getActiveSheet().rowFilter();
if (rowFilter.isFiltered(0)) {
alert("Row-filtering executed for Column1");
} else {
alert("Row-filtering not executed for Column1");
}
});
//Add button control to page
<input type="button" id="button1" value="button1"/>
Name | Type |
---|---|
col? |
number |
boolean
No parameter true
if some rows are filtered; otherwise, false
.
One parameter col true
if the specified column is filtered; otherwise, false
.
▸ isRowFilteredOut(row
): boolean
Determines whether the specified row is filtered out.
example
sheet.setRowCount(2);
sheet.setColumnCount(1);
sheet.setArray(0, 0,
[
[ 1 ],
[ 2 ]
] );
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,expected: '2'});
sheet.rowFilter().addFilterItem(0, condition);
sheet.rowFilter().filter(0);
sheet.addRows(1, 1);
console.log(sheet.rowFilter().isFiltered()); // true
console.log(sheet.rowFilter().isRowFilteredOut(0)); // true
console.log(sheet.rowFilter().isRowFilteredOut(1)); // false
Name | Type | Description |
---|---|---|
row |
number |
The row index. |
boolean
true
if the row is filtered out; otherwise, false
.
▸ onFilter(args
): void
Performs the action when some columns have just been filtered or unfiltered.
example
sheet.setRowCount(3);
sheet.setColumnCount(2);
sheet.setArray(0, 0,
[
[ 1, 2 ],
[ 3, 4 ],
[ 5, 6 ]
]);
function HighLightFilter(range) {
GC.Spread.Sheets.Filter.RowFilterBase.call(this, range);
}
HighLightFilter.prototype = new GC.Spread.Sheets.Filter.RowFilterBase(new GC.Spread.Sheets.Range(-1, -1, -1, -1));
var doFilterCalled = false;
HighLightFilter.prototype.onFilter = function(args) {
if ( args.action === GC.Spread.Sheets.Filter.FilterActionType.filter ) {
doFilterCalled = true;
}
};
sheet.rowFilter(new HighLightFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan, expected: 1 });
sheet.rowFilter().addFilterItem(0, condition);
sheet.rowFilter().filter();
console.log(doFilterCalled); // true
Name | Type | Description |
---|---|---|
args |
IFilteredArgs |
An object that contains the action, sheet, range, filteredRows, filteredOutRows, and columns. |
void
▸ openFilterDialog(filterButtonHitInfo
): void
Opens the filter dialog when the user clicks the filter button.
example
sheet.setRowCount(3);
sheet.setColumnCount(2);
sheet.setArray(0, 0,
[
[ 1, 2 ],
[ 3, 4 ],
[ 5, 6 ]
]);
function HighLightFilter(range) {
GC.Spread.Sheets.Filter.RowFilterBase.call(this, range);
}
HighLightFilter.prototype = new GC.Spread.Sheets.Filter.RowFilterBase(new GC.Spread.Sheets.Range(-1, -1, -1, -1));
HighLightFilter.prototype.openFilterDialog = function(args) {
console.log(args.row, args.col);
};
sheet.rowFilter(new HighLightFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
Name | Type | Description |
---|---|---|
filterButtonHitInfo |
IFilterButtonHitInfo |
The hit test information about the filter button. |
void
▸ removeFilterItems(col
): void
Removes the specified filter.
example
sheet.setRowCount(3);
sheet.setColumnCount(1);
sheet.setArray(0, 0,
[
[ 1 ],
[ 2 ],
[ 3 ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range( -1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo, expected: '3'});
var rowFilter = sheet.rowFilter();
rowFilter.addFilterItem(0, condition);
rowFilter.removeFilterItems(0);
Name | Type | Description |
---|---|---|
col |
number |
The column index. |
void
▸ reset(): void
Clears all filters.
example
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
sheet.rowFilter().reset();
console.log(sheet.rowFilter().isFiltered()); // false
void
▸ sortColumn(col
, ascending
): void
Sorts the specified column in the specified order.
example
sheet.setArray(0, 0, [
[ 4 ],
[ 3 ],
[ 2 ],
[ 1 ],
[ 0 ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(0, 0, 5, 1)));
sheet.rowFilter().addFilterItem(0, new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.numberCondition, { compareType: GC.Spread.Sheets.ConditionalFormatting.GeneralComparisonOperators.greaterThan, expected: 2 }));
sheet.rowFilter().filter(0);
sheet.rowFilter().sortColumn(0, true);
Name | Type | Description |
---|---|---|
col |
number |
The column index. |
ascending |
boolean |
Set to true to sort as ascending. |
void
▸ toJSON(): Object
Saves the object state to a JSON string.
Object
The row filter data.
▸ unfilter(col?
): void
Removes the filter from the specified column.
example
sheet.setRowCount(2);
sheet.setColumnCount(1);
sheet.setArray(0, 0,
[
[ "a" ],
[ "b" ]
]);
sheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, -1, -1, -1)));
var condition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo,expected: 'a'});
var rowFilter = sheet.rowFilter();
rowFilter.addFilterItem(0, condition);
rowFilter.unfilter();
Name | Type |
---|---|
col? |
number |
void