diff --git a/src/BlazorTable.Sample.Shared/Pages/GlobalSearch.razor b/src/BlazorTable.Sample.Shared/Pages/GlobalSearch.razor index 1e90b5d6..7993b3e6 100644 --- a/src/BlazorTable.Sample.Shared/Pages/GlobalSearch.razor +++ b/src/BlazorTable.Sample.Shared/Pages/GlobalSearch.razor @@ -4,9 +4,7 @@

Global Search

-Search: - - +
@@ -38,8 +36,6 @@ Search: Table; - private PersonData[] data; protected override async Task OnInitializedAsync() diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor index 344089e2..1710b3ec 100644 --- a/src/BlazorTable/Components/Table.razor +++ b/src/BlazorTable/Components/Table.razor @@ -3,144 +3,155 @@ @if (Columns.Any()) { -
- - +
+
+ @if (ShowSearchBar) + { + + + + + + } - @if (_detailTemplate != null) - { - - } - @foreach (IColumn column in Columns) - { - + -
- @column.Title + @if (_detailTemplate != null) + { +
+ } + @foreach (IColumn column in Columns) + { + - } - - - - @if (FilteredItems != null) - { - if (FilteredItems.Any()) - { - int i = 0; + @if (column.SortColumn) + { + if (column.SortDescending) + { } + else + { } + } - foreach (TableItem item in FilteredItems) + @if (column.Filterable) + { +
+ 🔍 +
+ + +

Filter

+
+ + + + + + + @if (column.CustomIFilters != null) + { + @column.CustomIFilters(column) + } + +
+
+
+ } + + + } + + + + @if (FilteredItems != null) + { + if (FilteredItems.Any()) { - + int i = 0; - @{int locali = i;} - @if (_detailTemplate != null) - { - - } + foreach (TableItem item in FilteredItems) + { + - @foreach (IColumn column in Columns) - { - + } - @if (IsEditMode && column.EditTemplate != null) - @column.EditTemplate(item) - else - if (column.Template == null) - @column.Render(item) - else - @column.Template(item) - - } - + @foreach (IColumn column in Columns) + { + - - + @if (IsEditMode && column.EditTemplate != null) + @column.EditTemplate(item) + else + if (column.Template == null) + @column.Render(item) + else + @column.Template(item) + + } - } - { i = locali + 1; } + if (_detailTemplate != null && detailsViewOpen[locali]) + { + + + + + } + + { i = locali + 1; } + } + } + else if (_emptyDataTemplate != null) + { + + + } } - else if (_emptyDataTemplate != null) + else { } - } - else - { - - - - } - -
- +
+ - @if (column.SortColumn) - { - if (column.SortDescending) - { } - else - { } - } +
+ @column.Title - @if (column.Filterable) - { -
- 🔍 -
- - -

Filter

-
- - - - - - - @if (column.CustomIFilters != null) - { - @column.CustomIFilters(column) - } - -
-
-
- } -
-
- @(detailsViewOpen[locali] ? "➖" : "➕") -
+ @{int locali = i;} + @if (_detailTemplate != null) + { + + @(detailsViewOpen[locali] ? "➖" : "➕") +
- if (_detailTemplate != null && detailsViewOpen[locali]) - { -
- @_detailTemplate(item) -
+ @_detailTemplate(item) +
+ @_emptyDataTemplate +
- @_emptyDataTemplate + @if (_loadingDataTemplate != null) + { + @_loadingDataTemplate + } + else + { +
+ Loading... +
+ }
- @if (_loadingDataTemplate != null) - { - @_loadingDataTemplate - } - else - { -
- Loading... -
- } -
+ + + } @ChildContent - \ No newline at end of file + diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index c2f16a28..18131af1 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -450,5 +450,11 @@ private Expression> GlobalSearchQuery(string value) return expression; } + + /// + /// Shows Search Bar above the table + /// + [Parameter] + public bool ShowSearchBar { get; set; } } } diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs index df6aa317..d2634276 100644 --- a/src/BlazorTable/Interfaces/ITable.cs +++ b/src/BlazorTable/Interfaces/ITable.cs @@ -107,5 +107,10 @@ public interface ITable /// Search all columns for the specified string, supports spaces as a delimiter /// string GlobalSearch { get; set; } + + /// + /// Shows Search Bar above the table + /// + bool ShowSearchBar { get; set; } } } \ No newline at end of file