Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from IvanJosipovic/dev
Browse files Browse the repository at this point in the history
v0.0.7-preview1
  • Loading branch information
IvanJosipovic authored Oct 26, 2019
2 parents a759780 + 76ee580 commit e8bee8f
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 193 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@master
uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@master
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.402
- name: SonarQube Install
Expand All @@ -22,7 +22,7 @@ jobs:
env:
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
- name: Setup .NET Core
uses: actions/setup-dotnet@master
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100-preview1-014459
- name: Dotnet Build
Expand All @@ -31,7 +31,7 @@ jobs:
working-directory: src/BlazorTable.Sample
run: dotnet publish --configuration Release
- name: Setup .NET Core
uses: actions/setup-dotnet@master
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.402
- name: SonarQube End
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

A simple Table Control for Blazor




## Features
- Edit Mode ([Template Switching](/src/BlazorTable.Sample/Pages/EditMode.razor))
- Client Side
Expand All @@ -21,11 +18,11 @@ A simple Table Control for Blazor
- Strings
- Numbers
- Dates

- Custom Component
## Todo
- Client Side
- Filtering
- Custom Component
- Enums
- Remove dependency on Bootstrap + BlazorStrap


Expand All @@ -34,37 +31,37 @@ A simple Table Control for Blazor

```csharp
<Table TableItem="PersonData" Items="data" PageSize="15">
<Column TableItem="PersonData" Title="Id" Property="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Id" Field="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.id
</Template>
</Column>
<Column TableItem="PersonData" Title="First Name" Property="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="First Name" Field="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.first_name
</Template>
</Column>
<Column TableItem="PersonData" Title="Last Name" Property="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Last Name" Field="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.last_name
</Template>
</Column>
<Column TableItem="PersonData" Title="Email" Property="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Email" Field="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Template>
<a href="mailto:@context.email">@context.email</a>
</Template>
</Column>
<Column TableItem="PersonData" Title="Confirmed" Property="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Confirmed" Field="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.confirmed.ToString()
</Template>
</Column>
<Column TableItem="PersonData" Title="Fund" Property="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Fund" Field="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Template>
$@context.fund
</Template>
</Column>
<Column TableItem="PersonData" Title="Created Date" Property="@(x => x.created_date)" Sortable="true" Width="10%">
<Column TableItem="PersonData" Title="Created Date" Field="@(x => x.created_date)" Sortable="true" Width="10%">
<Template>
@context.created_date.ToShortDateString()
</Template>
Expand Down
42 changes: 21 additions & 21 deletions src/BlazorTable.Sample/Pages/EditMode.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,61 @@
<br />
<br />
<Table TableItem="PersonData" Items="data" PageSize="15" @ref="Table">
<Column TableItem="PersonData" Title="Id" Property="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Id" Field="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.id
</Template>
<EditorTemplate>
<EditTemplate>
<input type="number" @bind-value="@context.id" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="First Name" Property="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="First Name" Field="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.first_name
</Template>
<EditorTemplate>
<EditTemplate>
<input type="text" @bind-value="@context.first_name" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="Last Name" Property="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Last Name" Field="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.last_name
</Template>
<EditorTemplate>
<EditTemplate>
<input type="text" @bind-value="@context.last_name" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="Email" Property="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Email" Field="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Template>
<a href="mailto:@context.email">@context.email</a>
</Template>
<EditorTemplate>
<EditTemplate>
<input type="email" @bind-value="@context.email" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="Confirmed" Property="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Confirmed" Field="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.confirmed.ToString()
</Template>
<EditorTemplate>
<EditTemplate>
<input type="checkbox" @bind-value="@context.confirmed" class="form-control form-control-sm" checked="@(context.confirmed)"/>
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="Fund" Property="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Fund" Field="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Template>
@(context.fund.HasValue ? context.fund.Value.ToString("C") : string.Empty)
</Template>
<EditorTemplate>
<EditTemplate>
<input type="number" step=".01" @bind-value="@context.fund" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Column TableItem="PersonData" Title="Created Date" Property="@(x => x.created_date)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Created Date" Field="@(x => x.created_date)" Sortable="true" Filterable="true" Width="10%">
<Template>
@(context.created_date.HasValue ? context.created_date.Value.ToShortDateString() : string.Empty)
</Template>
<EditorTemplate>
<EditTemplate>
<input type="date" @bind-value="@context.created_date" class="form-control form-control-sm" />
</EditorTemplate>
</EditTemplate>
</Column>
<Pager TableItem="PersonData" ShowPageNumber="true" ShowTotalCount="true" />
</Table>
Expand Down
14 changes: 7 additions & 7 deletions src/BlazorTable.Sample/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@
<br />

<Table TableItem="PersonData" Items="data" PageSize="15">
<Column TableItem="PersonData" Title="Id" Property="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Id" Field="@(x => x.id)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.id
</Template>
</Column>
<Column TableItem="PersonData" Title="First Name" Property="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="First Name" Field="@(x => x.first_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.first_name
</Template>
</Column>
<Column TableItem="PersonData" Title="Last Name" Property="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Last Name" Field="@(x => x.last_name)" Sortable="true" Filterable="true" Width="20%">
<Template>
@context.last_name
</Template>
</Column>
<Column TableItem="PersonData" Title="Email" Property="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Column TableItem="PersonData" Title="Email" Field="@(x => x.email)" Sortable="true" Filterable="true" Width="20%">
<Template>
<a href="mailto:@context.email">@context.email</a>
</Template>
</Column>
<Column TableItem="PersonData" Title="Confirmed" Property="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Confirmed" Field="@(x => x.confirmed)" Sortable="true" Filterable="true" Width="10%">
<Template>
@context.confirmed.ToString()
</Template>
</Column>
<Column TableItem="PersonData" Title="Fund" Property="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Fund" Field="@(x => x.fund)" Sortable="true" Filterable="true" Width="10%">
<Template>
@(context.fund.HasValue ? context.fund.Value.ToString("C") : string.Empty)
</Template>
</Column>
<Column TableItem="PersonData" Title="Created Date" Property="@(x => x.created_date)" Sortable="true" Filterable="true" Width="10%">
<Column TableItem="PersonData" Title="Created Date" Field="@(x => x.created_date)" Sortable="true" Filterable="true" Width="10%">
<Template>
@(context.created_date.HasValue ? context.created_date.Value.ToShortDateString() : string.Empty)
</Template>
Expand Down
8 changes: 5 additions & 3 deletions src/BlazorTable/BlazorTable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<RazorLangVersion>3.0</RazorLangVersion>
<IsPackable>true</IsPackable>
<Title>BlazorFileSaver</Title>
<Description>A simple Table Control for Blazor</Description>
<Description>A Table Control for Blazor with Paging, Sorting, Filtering</Description>
<Authors>Ivan Josipovic</Authors>
<PackageProjectUrl>https://github.com/IvanJosipovic/BlazorTable</PackageProjectUrl>
<PackageTags>Blazor;Table;Grid;DataTable;Data;Sort;Filter;AspNetCore;AspNet</PackageTags>
<Version>0.0.6-alpha</Version>
<PackageReleaseNotes>Experimental</PackageReleaseNotes>
<Version>0.0.7-preview1</Version>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/IvanJosipovic/BlazorTable</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorTable/Components/Column.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<BooleanFilter TableItem="TableItem" />
<NumberFilter TableItem="TableItem" />
<DateFilter TableItem="TableItem" />
@*@if (this.CustomIFilters != null)
@if (this.CustomIFilters != null)
{
this.CustomIFilters(this);
}*@
}
</FilterManager>

</BlazorStrap.BSPopoverBody>
Expand Down
14 changes: 7 additions & 7 deletions src/BlazorTable/Components/Column.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class Column<TableItem> : IColumn<TableItem>
[Parameter]
public string Title
{
get { return _title ?? Property.GetPropertyMemberInfo()?.Name; }
get { return _title ?? Field.GetPropertyMemberInfo()?.Name; }
set { _title = value; }
}

Expand All @@ -31,13 +31,13 @@ public string Title
public RenderFragment<TableItem> Template { get; set; }

[Parameter]
public RenderFragment<TableItem> EditorTemplate { get; set; }
public RenderFragment<TableItem> EditTemplate { get; set; }

[Parameter]
public RenderFragment<Column<TableItem>> CustomIFilters { get; set; }

[Parameter]
public Expression<Func<TableItem, object>> Property { get; set; }
public Expression<Func<TableItem, object>> Field { get; set; }

public Expression<Func<TableItem, bool>> Filter { get; set; }

Expand All @@ -53,7 +53,7 @@ public string Title

public void Dispose()
{
this.Table.RemoveColumn(this);
Table.RemoveColumn(this);
}

protected override void OnInitialized()
Expand All @@ -63,17 +63,17 @@ protected override void OnInitialized()

protected override void OnParametersSet()
{
if ((Sortable && Property == null) || (Filterable && Property == null))
if ((Sortable && Field == null) || (Filterable && Field == null))
{
throw new InvalidOperationException($"Column {Title} Property parameter is null");
}

if (Title == null && Property == null)
if (Title == null && Field == null)
{
throw new InvalidOperationException("A Column has both Title and Property parameters null");
}

Type = Property?.GetPropertyMemberInfo().GetMemberUnderlyingType();
Type = Field?.GetPropertyMemberInfo().GetMemberUnderlyingType();
}

public void ToggleFilter()
Expand Down
4 changes: 0 additions & 4 deletions src/BlazorTable/Components/FilterManager.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public partial class FilterManager<TableItem>

[Inject] public ILogger<FilterManager<TableItem>> Logger { get; set; }

protected override void OnInitialized()
{
}

private void ApplyFilter()
{
Column.ToggleFilter();
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorTable/Components/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
@foreach (IColumn<TableItem> column in Columns)
{
<td>
@if (IsEditMode && column.EditorTemplate != null)
@if (IsEditMode && column.EditTemplate != null)
{
@column.EditorTemplate(item)
@column.EditTemplate(item)
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/BlazorTable/Components/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class Table<TableItem> : ITable<TableItem>
[Parameter]
public IEnumerable<TableItem> Items { get; set; }

[Inject] ILogger<ITable<TableItem>> Logger { get; set; }
[Inject] private ILogger<ITable<TableItem>> Logger { get; set; }

private IEnumerable<TableItem> TempItems { get; set; }

Expand Down Expand Up @@ -66,17 +66,17 @@ private IEnumerable<TableItem> GetData()

TotalCount = query.Count();

var sortColumn = Columns.FirstOrDefault(x => x.SortColumn);
var sortColumn = Columns.Find(x => x.SortColumn);

if (sortColumn != null)
{
if (sortColumn.SortDescending)
{
query = query.OrderByDescending(sortColumn.Property);
query = query.OrderByDescending(sortColumn.Field);
}
else
{
query = query.OrderBy(sortColumn.Property);
query = query.OrderBy(sortColumn.Field);
}
}

Expand Down
Loading

0 comments on commit e8bee8f

Please sign in to comment.