diff --git a/src/MatBlazor.Demo/Demo/DemoTable.razor b/src/MatBlazor.Demo/Demo/DemoTable.razor index f36474a4..0379e3ff 100644 --- a/src/MatBlazor.Demo/Demo/DemoTable.razor +++ b/src/MatBlazor.Demo/Demo/DemoTable.razor @@ -3,7 +3,14 @@
Example
- + + + + + + + + Name Price @@ -18,6 +25,10 @@ @code { + void TestRowGenerating() + { + System.Diagnostics.Debug.WriteLine("RowGenerating called successful."); + } public class Car { @@ -49,7 +60,14 @@ + TestRowGenerating()""> + + + + + + + Name Price @@ -90,6 +108,12 @@ new Car(""Ford Mondeo"", 16000, 120), }; + void TestRowGenerating() + { + System.Diagnostics.Debug.WriteLine(""RowGenerating called successful.""); + } + + } ")> diff --git a/src/MatBlazor/Components/MatTable/MatTable.razor b/src/MatBlazor/Components/MatTable/MatTable.razor index 8cfbf12c..fdf03291 100644 --- a/src/MatBlazor/Components/MatTable/MatTable.razor +++ b/src/MatBlazor/Components/MatTable/MatTable.razor @@ -14,6 +14,7 @@ } + @MatColGroup @if (UseSortHeaderRow) { @@ -27,6 +28,7 @@ @if (ItemList != null) { + @CallRowGenerating() @foreach (var item in ItemList) { MatTableRow { get; set; } + [Parameter] + public RenderFragment MatColGroup { get; set; } + + /// /// Not Functioning /// @@ -123,6 +129,9 @@ protected IEnumerable ItemList { get; set; } + [Parameter] + public Action OnRowsGenerating { get; set; } + private string[] FilteredColumns => FilterByColumnName?.Split(";") ?? Array.Empty(); protected override async Task OnInitializedAsync() @@ -154,7 +163,7 @@ if (PageSize <= 0) PageSize = 5; } - + StartPage = 1; CurrentPage = StartPage; @@ -458,7 +467,7 @@ foreach (var item in items) { - var values = properties.Where(x => x.GetValue(item, null).ToString() != null).Select(x => x.GetValue(item, null).ToString()); + var values = properties.Where(x => x.GetValue(item, null)?.ToString() != null).Select(x => x.GetValue(item, null).ToString()); if (!values.Any()) { @@ -474,4 +483,9 @@ return filteredCollection; } + string CallRowGenerating() + { + OnRowsGenerating?.Invoke(); + return ""; + } }