Commit 7be9c66d authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

changes for reapplyAutoFilter

parent 75fc3337
......@@ -560,7 +560,7 @@ var editor;
spreadsheet_api.prototype.asc_reapplyAutoFilter = function(displayName) {
var ws = this.wb.getWorksheet();
ws.asc_reapplyAutoFilter(displayName);
ws.reapplyAutoFilter(displayName);
};
spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName, color) {
......
......@@ -606,21 +606,19 @@
return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter};
},
reapplyAutoFilter: function (tableName, ar)
reapplyAutoFilter: function (displayName, ar)
{
var worksheet = this.worksheet;
var bUndoChanges = worksheet.workbook.bUndoChanges;
var bRedoChanges = worksheet.workbook.bRedoChanges;
var minChangeRow;
//**get filter**
var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter;
var colId = this._getColIdColumnByRange(filter, ar);
var index = this._getIndexByColId(autoFilter, colId);
if(filterObj.filter === null)
return;
if(filter === null)
return false;
History.Create_NewPoint();
History.StartTransaction();
......@@ -630,55 +628,34 @@
{
var hiddenObj = {start: filter.Ref.r1 + 1, h: null};
//TODO скрытие оптимизировать аналогично функции applyAutoFilter
var startRow = autoFilter && autoFilter.Ref ? autoFilter.Ref.r1 + 1 : filter.Ref.r1 + 1;
var endRow = autoFilter && autoFilter.Ref ? autoFilter.Ref.r2 : filter.Ref.r2;
for(var i = startRow; i <= endRow; i++)
{
var isHidden = false;
if(autoFilter.FilterColumns && autoFilter.FilterColumns.length)
isHidden = this._hiddenAnotherFilter(autoFilter.FilterColumns, colId, i, autoFilter.Ref.c1);
isHidden = this._hiddenAnotherFilter(autoFilter.FilterColumns, null, i, autoFilter.Ref.c1);
if(!isHidden)
{
var cell = worksheet.getCell3(i, colId + autoFilter.Ref.c1);
var isDateTimeFormat = cell.getNumFormat().isDateTimeFormat();
var currentValue = isDateTimeFormat ? cell.getValueWithoutFormat() : cell.getValueWithFormat();
var isSetHidden = newFilterColumn.isHideValue(currentValue, isDateTimeFormat, null, cell);
if(isSetHidden !== worksheet.getRowHidden(i) && minChangeRow === null)
minChangeRow = i;
//скрываем строки
if(hiddenObj.h === null)
{
hiddenObj.h = isSetHidden;
hiddenObj.start = i;
}
else if(hiddenObj.h !== isSetHidden)
{
worksheet.setRowHidden(hiddenObj.h, hiddenObj.start, i - 1);
hiddenObj.h = isSetHidden;
hiddenObj.start = i;
}
if(i === endRow)
if(isHidden !== worksheet.getRowHidden(i))
{
if(minChangeRow === null)
{
worksheet.setRowHidden(hiddenObj.h, hiddenObj.start, i);
minChangeRow = i;
}
}
else if(hiddenObj.h !== null)
if(true === isHidden)
{
worksheet.setRowHidden(hiddenObj.h, hiddenObj.start, i - 1);
hiddenObj.h = null
worksheet.setRowHidden(isHidden, i, i);
}
}
}
this._resetTablePartStyle();
History.EndTransaction();
return {minChangeRow: minChangeRow, updateRange: filter.Ref};
},
checkRemoveTableParts: function(delRange, tableRange)
......
......@@ -12017,11 +12017,13 @@
return;
}
t.model.autoFilters.reapplyAutoFilter( tableName, ar );
if(null !== rangeOldFilter && !t.model.workbook.bUndoChanges && !t.model.workbook.bRedoChanges)
var applyFilterProps = t.model.autoFilters.reapplyAutoFilter( tableName, ar );
var rowChange = applyFilterProps.rowChange;
var updateRange = applyFilterProps.updateRange;
if(updateRange && !t.model.workbook.bUndoChanges && !t.model.workbook.bRedoChanges)
{
t._onUpdateFormatTable(rangeOldFilter, false, true);
t._onUpdateFormatTable(updateRange, false, true);
}
if ( null !== rowChange ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment