Skip to content

Commit

Permalink
♻ refactor(datatable): calculate real width of col on colgroup item
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Jan 5, 2024
1 parent 812c2ad commit 5f4f61c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Masa.Blazor/Components/DataTable/MDataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ protected override void SetComponentClass()
Select(item, val);
});
})
.Apply(typeof(BDataTableColgroup<>), typeof(MDataTableColgroup<TItem>), attrs =>
{
attrs[nameof(MDataTableColgroup<TItem>.Headers)] = ComputedHeaders;
})
.Apply(typeof(BDataTableRow<>), typeof(MDataTableRow<TItem>), attrs =>
{
attrs[nameof(MDataTableRow<TItem>.Headers)] = ComputedHeaders;
Expand Down
17 changes: 17 additions & 0 deletions src/Masa.Blazor/Components/DataTable/MDataTableColgroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Masa.Blazor;

public class MDataTableColgroup<TItem> : BDataTableColgroup<TItem>
{
[Inject] private MasaBlazor MasaBlazor { get; set; } = null!;

protected override void SetComponentCss()
{
base.SetComponentCss();

CssProvider.Apply("col", css =>
{
var header = css.Data as DataTableHeader;
css.AddIf("divider", () => header?.Divider is true);
});
}
}
1 change: 1 addition & 0 deletions src/Masa.Blazor/Components/DataTable/MDataTableHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected override void SetComponentClass()

cssBuilder
.Add("sortable")
.AddIf("m-data-table__divider", () => header.Divider)
.AddIf("active", () => beingSorted)
.AddIf(() => isDesc ? "desc" : "asc", () => beingSorted);
}
Expand Down
1 change: 1 addition & 0 deletions src/Masa.Blazor/Services/MasaBlazorComponentTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class MasaBlazorComponentTypeMapper : IAbstractComponentTypeMapper
{
{ typeof(BSelectList<,,>), typeof(MSelectList<,,>) },
{ typeof(BCascaderColumn<,>), typeof(MCascaderColumn<,>) },
{ typeof(BDataTableColgroup<>), typeof(MDataTableColgroup<>) },
{ typeof(BDataTableRow<>), typeof(MDataTableRow<>) },
{ typeof(BDataTableMobileRow<>), typeof(MDataTableMobileRow<>) },
{ typeof(BTreeviewNode<,>), typeof(MTreeviewNode<,>) },
Expand Down

0 comments on commit 5f4f61c

Please sign in to comment.