Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatTable features #749

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Suggested implementations:
- ColGroup tag before <thead> ;

- OnRowGenerating custom action, after <tbody> rendering. It will allow to create dictionaries (by ex.) with object instance (from list) and ElementReference. It's usefull when you want to create a button on TableRow with drop down Menu, for set its reference to Menu instance when clicked.
  • Loading branch information
Henrique Clausing committed Oct 10, 2020

Verified

This commit was signed with the committer’s verified signature.
Sceat Sceat
commit 34cf229a1621c59324172a844e6ffbbd0e064661
28 changes: 26 additions & 2 deletions src/MatBlazor.Demo/Demo/DemoTable.razor
Original file line number Diff line number Diff line change
@@ -3,7 +3,14 @@
<h5 class="mat-h5">Example</h5>
<DemoContainer>
<Content>
<MatTable Items="@cars" class="mat-elevation-z5">
<MatTable Items="@cars" class="mat-elevation-z5" OnRowsGenerating="() => TestRowGenerating()">
<MatColGroup>
<colgroup>
<col span="1" style="width: 60%;">
<col span="1" style="width: auto;">
<col span="1" style="width: auto;">
</colgroup>
</MatColGroup>
<MatTableHeader>
<th>Name</th>
<th>Price</th>
@@ -18,6 +25,10 @@

@code
{
void TestRowGenerating()
{
System.Diagnostics.Debug.WriteLine("RowGenerating called successful.");
}

public class Car
{
@@ -49,7 +60,14 @@
</Content>
<SourceContent>
<BlazorFiddle Template="MatBlazor" Code=@(@"
<MatTable Items=""@cars"" class=""mat-elevation-z5"">
<MatTable Items=""@cars"" class=""mat-elevation-z5"" OnRowsGenerating=""() => TestRowGenerating()"">
<MatColGroup>
<colgroup>
<col span=""1"" style=""width: 60%;"">
<col span=""1"" style=""width: auto;"">
<col span=""1"" style=""width: auto;"">
</colgroup>
</MatColGroup>
<MatTableHeader>
<th>Name</th>
<th>Price</th>
@@ -90,6 +108,12 @@
new Car(""Ford Mondeo"", 16000, 120),
};

void TestRowGenerating()
{
System.Diagnostics.Debug.WriteLine(""RowGenerating called successful."");
}


}

")></BlazorFiddle>
16 changes: 15 additions & 1 deletion src/MatBlazor/Components/MatTable/MatTable.razor
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
}
<CascadingValue Value="@this">
<table class="@ClassMapper.AsString()" style="@StyleMapper.AsString()" @ref="Ref" @attributes="Attributes" Id="@Id">
@MatColGroup
<thead>
@if (UseSortHeaderRow)
{
@@ -27,6 +28,7 @@
<tbody>
@if (ItemList != null)
{
@CallRowGenerating()
@foreach (var item in ItemList)
{
<TableRow Class="@RowClass"
@@ -109,6 +111,10 @@
[Parameter]
public RenderFragment<TableItem> MatTableRow { get; set; }

[Parameter]
public RenderFragment MatColGroup { get; set; }


/// <summary>
/// Not Functioning
/// </summary>
@@ -123,6 +129,9 @@

protected IEnumerable<TableItem> ItemList { get; set; }

[Parameter]
public Action OnRowsGenerating { get; set; }

private string[] FilteredColumns => FilterByColumnName?.Split(";") ?? Array.Empty<string>();

protected override async Task OnInitializedAsync()
@@ -154,7 +163,7 @@
if (PageSize <= 0)
PageSize = 5;
}

StartPage = 1;
CurrentPage = StartPage;

@@ -474,4 +483,9 @@
return filteredCollection;
}

string CallRowGenerating()
{
OnRowsGenerating?.Invoke();
return "";
}
}