Posted 25 May 2021, 7:07 pm EST - Updated 3 October 2022, 12:47 am EST
We are using spreadJS 14, and providing a functionality of “Row-set” by which user can add row-set in the sheet and marks the different rows corresponds to the newly added row-set(test1,test2) as shown in screenshot.
Based on the selected row set only rows which are marked under that row set should be visible and rest should be hidden.
For Example
we have added 3 row-set (Basic-row-set, test1, test2) in view tab under ribbon.
Basic row set :- No marked row , all rows should visible if selected(default rowset).
test1: - few marked row
ex. markedrow[4,5,7,8,10,11,12].
Only these rows should be visible.
test2: - few marked row
ex. markedrow[100, 105,110,135,145,156,700,810].
Only these rows should be visible.
In this sheet, we have 5254 rows and can be more in other sheet. We have selected the ‘test1’ rowset and only those rows are visible which are under marked rows. So, we use the traditional ‘for-loop’ to show or hide the rows in spread using “setRowVisible” method as shown in code.
var startRow = area.AreaBeginRow;
var endRow = area.AreaEndRow;
var hideRows = sheet.HiddenRowsTable;
var dataBeginRow = area.DataBeginRow;
for (var i = startRow; i <= endRow; i++) { var row = i; var MarkedRow = _.find(rowSet.MarkedRows, function (o) { return o == i; }); if (MarkedRow != undefined || sheet.DefaultRowSet) { this.hideShowRow(activeSheet, row, true); } else { this.hideShowRow(activeSheet, row, false); } }
private hideShowRow(sheet: any, row: number, show: boolean): void {
sheet.setRowVisible(row, show);
}
In this case for -loop is taking time(2-3 mins or more depends on no. of rows ) to evaluate this row set functionality.
Please suggest, if there is any other way to show / hide the groups of row in one go/ or without looping.