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

changes for reapplyAutoFilter

parent 75fc3337
...@@ -560,7 +560,7 @@ var editor; ...@@ -560,7 +560,7 @@ var editor;
spreadsheet_api.prototype.asc_reapplyAutoFilter = function(displayName) { spreadsheet_api.prototype.asc_reapplyAutoFilter = function(displayName) {
var ws = this.wb.getWorksheet(); var ws = this.wb.getWorksheet();
ws.asc_reapplyAutoFilter(displayName); ws.reapplyAutoFilter(displayName);
}; };
spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName, color) { spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName, color) {
......
...@@ -606,21 +606,19 @@ ...@@ -606,21 +606,19 @@
return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter}; return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter};
}, },
reapplyAutoFilter: function (tableName, ar) reapplyAutoFilter: function (displayName, ar)
{ {
var worksheet = this.worksheet; var worksheet = this.worksheet;
var bUndoChanges = worksheet.workbook.bUndoChanges; var bUndoChanges = worksheet.workbook.bUndoChanges;
var bRedoChanges = worksheet.workbook.bRedoChanges; var bRedoChanges = worksheet.workbook.bRedoChanges;
var minChangeRow;
//**get filter** //**get filter**
var filter = this._getFilterByDisplayName(displayName); var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter; 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) if(filter === null)
return; return false;
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
...@@ -630,55 +628,34 @@ ...@@ -630,55 +628,34 @@
{ {
var hiddenObj = {start: filter.Ref.r1 + 1, h: null}; 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 startRow = autoFilter && autoFilter.Ref ? autoFilter.Ref.r1 + 1 : filter.Ref.r1 + 1;
var endRow = autoFilter && autoFilter.Ref ? autoFilter.Ref.r2 : filter.Ref.r2; var endRow = autoFilter && autoFilter.Ref ? autoFilter.Ref.r2 : filter.Ref.r2;
for(var i = startRow; i <= endRow; i++) for(var i = startRow; i <= endRow; i++)
{ {
var isHidden = false; var isHidden = false;
if(autoFilter.FilterColumns && autoFilter.FilterColumns.length) 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) if(isHidden !== worksheet.getRowHidden(i))
{ {
var cell = worksheet.getCell3(i, colId + autoFilter.Ref.c1); if(minChangeRow === null)
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; minChangeRow = i;
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(true === isHidden)
{ {
worksheet.setRowHidden(hiddenObj.h, hiddenObj.start, i); worksheet.setRowHidden(isHidden, i, i);
}
}
else if(hiddenObj.h !== null)
{
worksheet.setRowHidden(hiddenObj.h, hiddenObj.start, i - 1);
hiddenObj.h = null
} }
} }
} }
this._resetTablePartStyle(); this._resetTablePartStyle();
History.EndTransaction(); History.EndTransaction();
return {minChangeRow: minChangeRow, updateRange: filter.Ref};
}, },
checkRemoveTableParts: function(delRange, tableRange) checkRemoveTableParts: function(delRange, tableRange)
......
...@@ -12017,11 +12017,13 @@ ...@@ -12017,11 +12017,13 @@
return; return;
} }
t.model.autoFilters.reapplyAutoFilter( tableName, ar ); var applyFilterProps = t.model.autoFilters.reapplyAutoFilter( tableName, ar );
var rowChange = applyFilterProps.rowChange;
var updateRange = applyFilterProps.updateRange;
if(null !== rangeOldFilter && !t.model.workbook.bUndoChanges && !t.model.workbook.bRedoChanges) if(updateRange && !t.model.workbook.bUndoChanges && !t.model.workbook.bRedoChanges)
{ {
t._onUpdateFormatTable(rangeOldFilter, false, true); t._onUpdateFormatTable(updateRange, false, true);
} }
if ( null !== rowChange ) { 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