@@ -259,6 +259,12 @@ function createTable(tableSchema, tableData) {
259259 * @param {* } tableSchema Frictionless data table schema config.
260260 */
261261function createTableColumns ( tableSchema ) {
262+
263+ if ( viewState . tableConfig . columns ) {
264+ // use columns from restored table view config
265+ return viewState . tableConfig . columns ;
266+ }
267+
262268 const tableColumns = [ ] ;
263269 // Note: sometimes table rows are not parsed correctly
264270 // by the frictionless table schema infer() and returns only 1 field
@@ -352,23 +358,25 @@ function onTableBuilt () {
352358
353359 // get table columns for debug
354360 const columns = table . getColumns ( ) ;
355- console . log ( 'tableView.onTableBuilt():columns:' , columns ) ;
356-
357- // add row selection column
358- // TODO: make this optional via tabular data viewer config setting
359- table . addColumn ( {
360- formatter : 'rowSelection' ,
361- titleFormatter : 'rowSelection' ,
362- headerMenu : [ ] , // don't show header context menu
363- headerSort : false ,
364- download : false // don't include it in data save
365- } , true ) // add as 1st column
366- . then ( function ( column ) { // column - row selection colulmn component
367- } )
368- . catch ( function ( error ) {
369- // log adding row selection column error for now
370- console . error ( 'tableView.addRowSelectionCollumn: Error\n' , error ) ;
371- } ) ;
361+ // console.log('tableView.onTableBuilt():columns:', columns);
362+
363+ if ( tableColumns . length > 0 && tableColumns [ 0 ] . formatter !== 'rowSelection' ) {
364+ // add row selection column
365+ // TODO: make this optional via tabular data viewer config setting
366+ table . addColumn ( {
367+ formatter : 'rowSelection' ,
368+ titleFormatter : 'rowSelection' ,
369+ headerMenu : [ ] , // don't show header context menu
370+ headerSort : false ,
371+ download : false // don't include it in data save
372+ } , true ) // add as 1st column
373+ . then ( function ( column ) { // column - row selection colulmn component
374+ } )
375+ . catch ( function ( error ) {
376+ // log adding row selection column error for now
377+ console . error ( 'tableView.addRowSelectionCollumn: Error\n' , error ) ;
378+ } ) ;
379+ }
372380
373381 // request more data for incremental data loading
374382 loadedRows = table . getRows ( ) . length ;
@@ -466,7 +474,7 @@ function clearTable(table) {
466474function saveTableSetting ( id , type , data ) {
467475 // create table setting key
468476 const tableSettingKey = `${ id } -${ type } ` ;
469- console . log ( `tableView.saveTableSetting(): ${ tableSettingKey } =` , data ) ;
477+ // console.log(`tableView.saveTableSetting(): ${tableSettingKey}=`, data);
470478
471479 // save table setting in local storage
472480 localStorage . setItem ( tableSettingKey , JSON . stringify ( data ) ) ;
@@ -479,7 +487,8 @@ function saveTableSetting(id, type, data) {
479487 // update table config in view state
480488 tableConfig [ type ] = data ;
481489 vscode . setState ( viewState ) ;
482- console . log ( `tableView.saveTableSetting():viewState` , viewState ) ;
490+
491+ // console.log(`tableView.saveTableSetting():viewState`, viewState);
483492}
484493
485494/**
0 commit comments