File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
src/BootstrapBlazor/Components/Table Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -714,7 +714,10 @@ const indexOfCol = col => {
714714
715715const autoFitColumnWidth = async ( table , col ) => {
716716 const field = col . getAttribute ( 'data-bb-field' ) ;
717- const widthValue = await table . invoke . invokeMethodAsync ( table . options . autoFitContentCallback , field ) ;
717+ let widthValue = 0 ;
718+ if ( table . options . autoFitContentCallback !== null ) {
719+ widthValue = await table . invoke . invokeMethodAsync ( table . options . autoFitContentCallback , field ) ;
720+ }
718721
719722 const index = indexOfCol ( col ) ;
720723 let rows = null ;
@@ -725,11 +728,13 @@ const autoFitColumnWidth = async (table, col) => {
725728 rows = table . tables [ 0 ] . querySelectorAll ( 'table > tbody > tr:not(.is-detail)' ) ;
726729 }
727730
728- let maxWidth = 0 ;
729- [ ...rows ] . forEach ( row => {
730- const cell = row . cells [ index ] ;
731- maxWidth = Math . max ( maxWidth , calcCellWidth ( cell ) ) ;
732- } ) ;
731+ let maxWidth = widthValue ;
732+ if ( maxWidth === 0 ) {
733+ [ ...rows ] . forEach ( row => {
734+ const cell = row . cells [ index ] ;
735+ maxWidth = Math . max ( maxWidth , calcCellWidth ( cell ) ) ;
736+ } ) ;
737+ }
733738
734739 if ( maxWidth > 0 ) {
735740 table . tables . forEach ( table => {
You can’t perform that action at this time.
0 commit comments