From d7d4731f80c7a25de4bd8a4af8a4b7c634cbe957 Mon Sep 17 00:00:00 2001 From: jamessspanggg Date: Tue, 21 Jan 2020 01:56:03 +0800 Subject: [PATCH] Utilise callbacks to chain fill/blank down operations --- .../views/data-table/data-table-view.js | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js index 7e5d6a6fb..ab31a4c27 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js @@ -875,27 +875,45 @@ DataTableView.prototype._createSortingMenu = function(elmt) { }; var doAllFillDown = function() { - for (var i = 0; i < theProject.columnModel.columns.length; i++) { + doFillDown(0); +}; + +var doFillDown = function(colIndex) { + if (colIndex < theProject.columnModel.columns.length) { Refine.postCoreProcess( "fill-down", { - columnName: theProject.columnModel.columns[i].name + columnName: theProject.columnModel.columns[colIndex].name }, null, - { modelsChanged: true } + {modelsChanged: true}, + { + onDone: function() { + doFillDown(++colIndex); + } + } ); } }; var doAllBlankDown = function() { - for (var i = 0; i < theProject.columnModel.columns.length; i++) { + doBlankDown(0); +}; + +var doBlankDown = function(colIndex) { + if (colIndex < theProject.columnModel.columns.length) { Refine.postCoreProcess( "blank-down", { - columnName: theProject.columnModel.columns[i].name + columnName: theProject.columnModel.columns[colIndex].name }, null, - { modelsChanged: true } + { modelsChanged: true }, + { + onDone: function() { + doBlankDown(++colIndex); + } + } ); } };