@@ -96,6 +96,9 @@ window.addEventListener('resize', function () {
9696// add data/config update handler
9797window . addEventListener ( 'message' , event => {
9898 switch ( event . data . command ) {
99+ case 'createTable' :
100+ createTable ( event . data . tableSchema ) ;
101+ break ;
99102 case 'refresh' :
100103 documentUrl = event . data . documentUrl ;
101104 fileName = event . data . fileName ;
@@ -171,7 +174,7 @@ function loadData(tableData, tableSchema) {
171174 logTableData ( tableData ) ;
172175 if ( table === undefined ) {
173176 // create table and load initial set of data rows
174- createTable ( tableData , tableSchema ) ;
177+ table = createTable ( tableSchema , tableData ) ;
175178 }
176179 else {
177180 // add new data rows to existing tabulator table
@@ -183,11 +186,14 @@ function loadData(tableData, tableSchema) {
183186/**
184187 * Creates new Tabulator table with initial set of data to display.
185188 *
186- * @param {* } tableData Data array to display in tabulator table.
187189 * @param {* } tableSchema Data table schema with inferred column fields info.
190+ * @param {* } tableData Data array to display in tabulator table.
188191 */
189- function createTable ( tableData , tableSchema ) {
192+ function createTable ( tableSchema , tableData ) {
190193 if ( table === undefined ) {
194+ // show progress ring
195+ progressRing . style . visibility = 'visible' ;
196+
191197 // create table columns array from table schema fields
192198 tableColumns = createTableColumns ( tableSchema ) ;
193199 if ( tableColumns . length > 0 ) {
@@ -207,6 +213,7 @@ function createTable(tableData, tableSchema) {
207213 console . log ( 'tableView.table.dataLoaded():loadedData:' , data . length . toLocaleString ( ) ) ;
208214 } ) ;
209215 }
216+ return table ;
210217}
211218
212219/**
@@ -221,7 +228,7 @@ function createTableColumns(tableSchema) {
221228 // Note: sometimes table rows are not parsed correctly
222229 // by the frictionless table schema infer() and returns only 1 field
223230 if ( tableSchema && tableSchema . fields && tableSchema . fields . length > 1 ) {
224- console . log ( 'tableView.createTableColumns():tableSchema:' , tableSchema . fields ) ;
231+ // console.log('tableView.createTableColumns():tableSchema:', tableSchema.fields);
225232 tableSchema . fields . forEach ( field => {
226233 // determine field sorter type
227234 let sorter = 'string' ;
@@ -243,8 +250,8 @@ function createTableColumns(tableSchema) {
243250 } ) ;
244251 } ) ;
245252 console . log ( 'tableView.createTableColumns():columns:' , tableColumns ) ;
246- return tableColumns ;
247253 }
254+ return tableColumns ;
248255}
249256
250257/**
0 commit comments