File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
src/BootstrapBlazor/Components/Table Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -1065,7 +1065,7 @@ private async Task OnTableRenderAsync(bool firstRender)
10651065 await InvokeVoidAsync ( "init" , Id , Interop , new
10661066 {
10671067 DragColumnCallback = nameof ( DragColumnCallback ) ,
1068- AutoFitContentCallback = nameof ( AutoFitContentCallback ) ,
1068+ AutoFitContentCallback = OnAutoFitContentAsync == null ? null : nameof ( AutoFitContentCallback ) ,
10691069 ResizeColumnCallback = OnResizeColumnAsync != null ? nameof ( ResizeColumnCallback ) : null ,
10701070 ColumnMinWidth = ColumnMinWidth ?? Options . CurrentValue . TableSettings . ColumnMinWidth ,
10711071 ScrollWidth = ActualScrollWidth ,
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