@@ -321,6 +321,45 @@ const loadColumnsFromLayout = () => {
321321 columns .value = store .layout .columns .filter (col => ! col .hidden )
322322}
323323
324+ const tableWidth = computed (() => {
325+ if (! table .value ) {
326+ return 0 ;
327+ }
328+ return table .value .clientWidth - 20 // 20 for the scrollbar
329+ })
330+
331+ const columnsWithWidth = computed (() => {
332+ if (! table .value ) {
333+ return columns .value ;
334+ }
335+ let maxWCol = columns .value .find (c => c .width === ' *' )
336+
337+ if (maxWCol ) {
338+ let totalWidth = 0 ;
339+ columns .value .forEach (c => {
340+ if (c .id !== maxWCol ?.id ) {
341+ if (typeof c .width === ' string' ) {
342+ if (c .width .endsWith (' %' )) {
343+ totalWidth += tableWidth .value * (parseInt (c .width .slice (0 , - 1 )) / 100 )
344+ } else {
345+ totalWidth += parseInt (c .width )
346+ }
347+ } else {
348+ totalWidth += c .width || 0
349+ }
350+ }
351+ })
352+ maxWCol .width = (tableWidth .value - totalWidth ) + ' px'
353+ }
354+
355+ return columns .value .map (c => {
356+ if (typeof c .width === ' number' ) {
357+ c .width = c .width + ' px'
358+ }
359+ return c
360+ })
361+ })
362+
324363const addRawColumn = () => {
325364 columnEdited ({
326365 name: " raw" ,
@@ -703,7 +742,7 @@ const updateSampleLine = () => {
703742 <div class =" mid-col" :class =" { freeze: leftColHidden }" @mousedown =" startDragging" ></div >
704743 </div >
705744 <div class =" right-col" ref =" table" >
706- <div v-if =" columns .length === 0" style =" text-align : center ; padding-top :100px ; font-size : 20px ;" >
745+ <div v-if =" columnsWithWidth .length === 0" style =" text-align : center ; padding-top :100px ; font-size : 20px ;" >
707746
708747 <div v-if =" useMainStore().status == 'not connected'" style =" margin : 10px ; padding : 5px ;" >Status: <strong >Not
709748 connected</strong ></div >
@@ -723,7 +762,7 @@ const updateSampleLine = () => {
723762 <table class =" table" cellspacing =" 0" cellpadding =" 0" >
724763 <tr >
725764 <th ></th >
726- <th v-for =" col in columns " :style =" { width: col.width + 'px' , cursor: 'auto' }" class =" column-name"
765+ <th v-for =" col in columnsWithWidth " :style =" { width: col.width, cursor: 'auto' }" class =" column-name"
727766 @contextmenu.prevent =" useContextMenuStore().show($event, { type: 'column_header', name: col.name })" >
728767 <span style =" cursor : auto ;" >{{ col.name }}</span >
729768 <FilterIcon v-if =" col.faceted" :style =" { opacity: store.isFacetActive(col.name) ? 1 : 0.2 }" />
@@ -745,15 +784,15 @@ const updateSampleLine = () => {
745784 ⬤
746785 </span >
747786 </td >
748- <td class =" cell" v-for =" c, k2 in columns " :style =" Object.assign(row.cells[k2].style as StyleValue || {},{
787+ <td class =" cell" v-for =" c, k2 in columnsWithWidth " :style =" Object.assign(row.cells[k2].style as StyleValue || {},{
749788 backgroundColor: (store.layout.settings.paintCorrelationIdCell && store.layout.settings.correlationIdField == c.name) ? hashStringToRgb(row.cells[k2].text||'', 40): ''
750789 } as StyleValue)"
751790 :class =" { 'cell-error': row.cells[k2].error }" >
752- <div v-if =" row.cells[k2].allowHtmlInText" :style =" { width: columns [k2].width + 'px' }"
791+ <div v-if =" row.cells[k2].allowHtmlInText" :style =" { width: columnsWithWidth [k2].width }"
753792 v-html =" row.cells[k2].text !== undefined ? row.cells[k2].text : row.cells[k2].error || '  ; '"
754793 @contextmenu.prevent =" useContextMenuStore().show($event, { type: 'cell', value: row.cells[k2].text, columnId: c.id, error: row.cells[k2].error })" >
755794 </div >
756- <div v-else :style =" { width: columns [k2].width + 'px' }"
795+ <div v-else :style =" { width: columnsWithWidth [k2].width }"
757796 @contextmenu.prevent =" useContextMenuStore().show($event, { type: 'cell', value: row.cells[k2].text, columnId: c.id, error: row.cells[k2].error })" >
758797 {{ row.cells[k2].text !== undefined ? row.cells[k2].text : row.cells[k2].error || "  ; " }}
759798 </div >
0 commit comments