Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(change sheet bug): multiple refresh canvas bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Aug 1, 2020
1 parent 04bc51c commit 7a625e0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/controllers/pivotTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ const pivotTable = {
_this.getCellData(index);
_this.initialPivotManage(true);
},
refreshPivotTable: function () {
refreshPivotTable: function (isRefreshCanvas=true) {
let _this = this;

let redo = {};
Expand Down Expand Up @@ -730,10 +730,10 @@ const pivotTable = {
Store.clearjfundo = false;

if (addr > 0 || addc > 0) {
jfrefreshgridall(data[0].length, data.length, data, null, Store.luckysheet_select_save, "datachangeAll");
jfrefreshgridall(data[0].length, data.length, data, null, Store.luckysheet_select_save, "datachangeAll", undefined, undefined,isRefreshCanvas);
}
else {
jfrefreshgrid(data, Store.luckysheet_select_save);
jfrefreshgrid(data, Store.luckysheet_select_save, isRefreshCanvas, undefined, undefined, undefined, false);
selectHightlightShow();
}

Expand Down Expand Up @@ -2345,7 +2345,7 @@ const pivotTable = {
$("#luckysheet-dialog-pivotTable-range").html(getRangetxt(_this.pivotDataSheetIndex, _this.pivot_select_save));
$("#luckysheet-modal-dialog-slider-pivot").show();

luckysheetsizeauto();
luckysheetsizeauto(false);
},
getComposeArray: function (data) {
if (data.length == 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/controllers/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sheetmanage from './sheetmanage';
let gridW = 0,
gridH = 0;

export default function luckysheetsizeauto() {
export default function luckysheetsizeauto(isRefreshCanvas=true) {
if (!luckysheetConfigsetting.showinfobar) {
Store.infobarHeight = 0;
$("#luckysheet_info_detail").hide();
Expand Down Expand Up @@ -104,7 +104,9 @@ export default function luckysheetsizeauto() {
.css({ "height": gridheight - 10 });

luckysheetFreezen.createAssistCanvas();
luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
if(isRefreshCanvas){
luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
}
const _locale = locale();
const locale_toolbar = _locale.toolbar;
let ismore = false,
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ const sheetmanage = {
formula.execFunctionGroup();
_this.restoreSheetAll(Store.currentSheetIndex);

luckysheetrefreshgrid(0, 0);
// luckysheetrefreshgrid(0, 0);
$("#luckysheet_info_detail_save").html(locale_info.detailSave);

if (!!file.isPivotTable) {
Expand Down Expand Up @@ -787,7 +787,7 @@ const sheetmanage = {

createFilterOptions(file["filter_select"], file["filter"]);

jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false);
},
restoreselect: function() {
let index = this.getSheetIndex(Store.currentSheetIndex);
Expand Down Expand Up @@ -1210,7 +1210,7 @@ const sheetmanage = {
file.config.rowhidden = {};
Store.config = file.config;

jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false);
}

return;
Expand Down Expand Up @@ -1265,7 +1265,7 @@ const sheetmanage = {
file.config["rowhidden"] = rowhidden;
Store.config = file.config;

jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false);
},
restorePivot: function(sheetIndex) {
let index = this.getSheetIndex(sheetIndex);
Expand All @@ -1277,7 +1277,7 @@ const sheetmanage = {

pivotTable.getCellData(sheetIndex);
pivotTable.initialPivotManage(true);
pivotTable.refreshPivotTable();
pivotTable.refreshPivotTable(false);
},
restoreSheetAll: function(sheetIndex) {
let _this= this;
Expand Down
4 changes: 2 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ luckysheet.create = function (setting) {
let data = [];
if (loadurl == "") {
sheetmanage.initialjfFile(menu, title);
luckysheetsizeauto();
// luckysheetsizeauto();
initialWorkBook();
}
else {
Expand All @@ -115,7 +115,7 @@ luckysheet.create = function (setting) {
Store.luckysheetfile = data;

sheetmanage.initialjfFile(menu, title);
luckysheetsizeauto();
// luckysheetsizeauto();
initialWorkBook();

//需要更新数据给后台时,建立WebSocket连接
Expand Down
33 changes: 21 additions & 12 deletions src/global/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { createFilterOptions } from '../controllers/filter';
import { getSheetIndex } from '../methods/get';
import Store from '../store';

function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction=true) {
function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction=true, isRefreshCanvas=true) {
if(data == null){
data = Store.flowdata;
}
Expand Down Expand Up @@ -122,14 +122,17 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
}

//刷新表格
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
if(isRefreshCanvas){
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
}


window.luckysheet_getcelldata_cache = null;
}

function jfrefreshgridall(colwidth, rowheight, data, cfg, range, ctrlType, ctrlValue, cdformat, changeSize) {
function jfrefreshgridall(colwidth, rowheight, data, cfg, range, ctrlType, ctrlValue, cdformat, isRefreshCanvas=true) {
let redo = {};

if (ctrlType == "cellRowChange") {
Expand Down Expand Up @@ -246,9 +249,12 @@ function jfrefreshgridall(colwidth, rowheight, data, cfg, range, ctrlType, ctrlV
//行高、列宽 刷新
jfrefreshgrid_rhcw(rowheight, colwidth);

setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
if(isRefreshCanvas){
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
}


sheetmanage.storeSheetParamALL();

Expand Down Expand Up @@ -633,7 +639,7 @@ function jfrefreshgrid_pastcut(source, target, RowlChange){
}

//行高、列宽改变 刷新表格
function jfrefreshgrid_rhcw(rowheight, colwidth){
function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas=true){
rhchInit(rowheight, colwidth);

sheetmanage.storeSheetParam();
Expand Down Expand Up @@ -786,9 +792,12 @@ function jfrefreshgrid_rhcw(rowheight, colwidth){

sheetmanage.showSheet();

setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
if(isRefreshCanvas){
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
}

}

//Refresh the canvas display data according to scrollHeight and scrollWidth
Expand Down

0 comments on commit 7a625e0

Please sign in to comment.