mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 03:57:38 +08:00
fix(module: table): scroll bar width adaptive (#4064)
This commit is contained in:
parent
ba605a16b8
commit
92144d0133
@ -210,7 +210,7 @@ namespace AntDesign
|
||||
|
||||
if (IsHeader && Table.ScrollY != null && Table.ScrollX != null && Fixed == "right")
|
||||
{
|
||||
fixedWidths = fixedWidths.Append($"{(CssSizeLength)Table.RealScrollBarSize}");
|
||||
fixedWidths = fixedWidths.Append($"{(CssSizeLength)Table.ScrollBarWidth}");
|
||||
}
|
||||
|
||||
var fixedWidth = fixedWidths.Length switch
|
||||
@ -232,5 +232,11 @@ namespace AntDesign
|
||||
RowData.Expanded = !RowData.Expanded;
|
||||
Table?.OnExpandChange(RowData);
|
||||
}
|
||||
|
||||
void IColumn.UpdateFixedStyle()
|
||||
{
|
||||
_fixedStyle = CalcFixedStyle();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,7 @@ namespace AntDesign
|
||||
public int RowSpan { get; set; }
|
||||
|
||||
public int HeaderColSpan { get; set; }
|
||||
|
||||
internal void UpdateFixedStyle();
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ namespace AntDesign
|
||||
|
||||
internal string ScrollBarWidth { get; }
|
||||
|
||||
internal string RealScrollBarSize { get; }
|
||||
|
||||
internal int ExpandIconColumnIndex { get; }
|
||||
|
||||
internal int TreeExpandIconColumnIndex { get; }
|
||||
|
@ -164,7 +164,7 @@
|
||||
|
||||
static RenderFragment colGroup(Table<TItem> table, bool header)
|
||||
{
|
||||
var realSize = (CssSizeLength)((table as ITable).RealScrollBarSize);
|
||||
var realSize = (CssSizeLength)((table as ITable).ScrollBarWidth);
|
||||
return @<colgroup>
|
||||
<CascadingValue Name="IsColGroup" Value="true" IsFixed>
|
||||
@if (_fieldModel is not null)
|
||||
|
@ -135,7 +135,7 @@ namespace AntDesign
|
||||
public string ScrollY { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ScrollBarWidth { get => _scrollBarWidth; set => _scrollBarWidth = value; }
|
||||
public string ScrollBarWidth { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int IndentSize { get; set; } = 15;
|
||||
@ -225,7 +225,6 @@ namespace AntDesign
|
||||
private bool _waitingReloadAndInvokeChange;
|
||||
private bool _treeMode;
|
||||
private string _scrollBarWidth;
|
||||
private string _realScrollBarSize = "15px";
|
||||
private bool _hasFixLeft;
|
||||
private bool _hasFixRight;
|
||||
private int _treeExpandIconColumnIndex;
|
||||
@ -266,8 +265,7 @@ namespace AntDesign
|
||||
int ITable.IndentSize => IndentSize;
|
||||
string ITable.ScrollX => ScrollX;
|
||||
string ITable.ScrollY => ScrollY;
|
||||
string ITable.ScrollBarWidth => _scrollBarWidth;
|
||||
string ITable.RealScrollBarSize => _scrollBarWidth ?? _realScrollBarSize;
|
||||
string ITable.ScrollBarWidth => _scrollBarWidth ?? "15px";
|
||||
int ITable.ExpandIconColumnIndex => ExpandIconColumnIndex + (_selection != null && _selection.ColIndex <= ExpandIconColumnIndex ? 1 : 0);
|
||||
int ITable.TreeExpandIconColumnIndex => _treeExpandIconColumnIndex;
|
||||
bool ITable.HasExpandTemplate => ExpandTemplate != null;
|
||||
@ -645,6 +643,8 @@ namespace AntDesign
|
||||
TableLayout = "fixed";
|
||||
}
|
||||
|
||||
_scrollBarWidth = ScrollBarWidth;
|
||||
|
||||
#if NET5_0_OR_GREATER
|
||||
if (UseItemsProvider)
|
||||
{
|
||||
@ -717,10 +717,11 @@ namespace AntDesign
|
||||
await JsInvokeAsync(JSInteropConstants.BindTableScroll, _wrapperRef, _tableBodyRef, _tableRef, _tableHeaderRef, ScrollX != null, ScrollY != null, Resizable);
|
||||
}
|
||||
|
||||
if (ScrollY != null && ScrollBarWidth == null)
|
||||
if (ScrollY != null && ScrollY != null && _scrollBarWidth == null)
|
||||
{
|
||||
var scrollBarSize = await ClientDimensionService.GetScrollBarSizeAsync();
|
||||
_realScrollBarSize = $"{scrollBarSize}px";
|
||||
_scrollBarWidth = $"{scrollBarSize}px";
|
||||
ColumnContext.HeaderColumns.LastOrDefault()?.UpdateFixedStyle();
|
||||
}
|
||||
|
||||
// To handle the case where JS is called asynchronously and does not render when there is a fixed header or are any fixed columns.
|
||||
|
Loading…
Reference in New Issue
Block a user