diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index 06163f9b..804d9087 100644
--- a/.github/workflows/cicd.yml
+++ b/.github/workflows/cicd.yml
@@ -27,11 +27,11 @@ jobs:
run: ./dotnet-sonarscanner begin /o:ivanjosipovic /k:IvanJosipovic_BlazorTable /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=${{ secrets.SONARQUBE_TOKEN }}
- name: Dotnet Build
- run: dotnet build --configuration Release
+ run: dotnet build -c Release
- name: Dotnet Publish
working-directory: src/BlazorTable.Sample.Wasm
- run: dotnet publish --configuration Release
+ run: dotnet publish -c Release
- name: SonarQube End
run: ./dotnet-sonarscanner end /d:sonar.login=${{ secrets.SONARQUBE_TOKEN }}
@@ -42,7 +42,7 @@ jobs:
id: netlify
uses: ivanjosipovic/actions/cli@master
with:
- args: deploy --json -d src/BlazorTable.Sample.Wasm/bin/Release/netstandard2.1/publish/BlazorTable.Sample.Wasm/dist/
+ args: deploy --json -d src/BlazorTable.Sample.Wasm/bin/Release/netstandard2.1/publish/wwwroot
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a753a3ad..ecee3129 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -29,24 +29,26 @@ jobs:
working-directory: src/BlazorTable
run: dotnet pack -c Release -p:Version=${{ steps.version.outputs.new_tag }}
- - name: Dotnet Nuget Push
+ - name: Dotnet Nuget Push
+ if: "!contains(github.event.head_commit.message, '#skip')"
working-directory: src/BlazorTable/bin/Release
run: dotnet nuget push BlazorTable.*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
continue-on-error: true
- name: Dotnet Publish
working-directory: src/BlazorTable.Sample.Wasm
- run: dotnet publish --configuration Release
+ run: dotnet publish -c Release
- name: Deploy to Production
uses: netlify/actions/cli@master
with:
- args: deploy --prod --json -d src/BlazorTable.Sample.Wasm/bin/Release/netstandard2.1/publish/BlazorTable.Sample.Wasm/dist/
+ args: deploy --prod --json -d src/BlazorTable.Sample.Wasm/bin/Release/netstandard2.1/publish/wwwroot
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Create Release
+ if: "!contains(github.event.head_commit.message, '#skip')"
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/src/BlazorTable.Sample.Server/BlazorTable.Sample.Server.csproj b/src/BlazorTable.Sample.Server/BlazorTable.Sample.Server.csproj
index 25afae5e..340e9dbd 100644
--- a/src/BlazorTable.Sample.Server/BlazorTable.Sample.Server.csproj
+++ b/src/BlazorTable.Sample.Server/BlazorTable.Sample.Server.csproj
@@ -4,10 +4,6 @@
netcoreapp3.1
-
-
-
-
diff --git a/src/BlazorTable.Sample.Server/Properties/launchSettings.json b/src/BlazorTable.Sample.Server/Properties/launchSettings.json
index 44b37566..046786b2 100644
--- a/src/BlazorTable.Sample.Server/Properties/launchSettings.json
+++ b/src/BlazorTable.Sample.Server/Properties/launchSettings.json
@@ -18,7 +18,6 @@
"BlazorTable.Sample.Server": {
"commandName": "Project",
"launchBrowser": true,
- "launchUrl": "/CustomSelect",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
diff --git a/src/BlazorTable.Sample.Shared/BlazorTable.Sample.Shared.csproj b/src/BlazorTable.Sample.Shared/BlazorTable.Sample.Shared.csproj
index d8459039..a45fa5e6 100644
--- a/src/BlazorTable.Sample.Shared/BlazorTable.Sample.Shared.csproj
+++ b/src/BlazorTable.Sample.Shared/BlazorTable.Sample.Shared.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/BlazorTable.Sample.Shared/NavMenu.razor b/src/BlazorTable.Sample.Shared/NavMenu.razor
index 303e9176..337f636f 100644
--- a/src/BlazorTable.Sample.Shared/NavMenu.razor
+++ b/src/BlazorTable.Sample.Shared/NavMenu.razor
@@ -12,6 +12,11 @@
Home
+
+
+ Row
+
+
Edit Mode
diff --git a/src/BlazorTable.Sample.Shared/Pages/Row.razor b/src/BlazorTable.Sample.Shared/Pages/Row.razor
new file mode 100644
index 00000000..144728ea
--- /dev/null
+++ b/src/BlazorTable.Sample.Shared/Pages/Row.razor
@@ -0,0 +1,80 @@
+@page "/Row"
+
+@using BlazorTable
+
+Row
+
+Selection Type:
+
+
+Last Clicked: @selected?.full_name
+
+Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggregate((c, n) => $"{c},{n}") : "None")
+
+
+
+
+
+
+ @context.email
+
+
+
+
+
+
+ @(context.created_date.HasValue ? context.created_date.Value.ToShortDateString() : string.Empty)
+
+
+
+
+
+
+@code
+{
+ [Inject]
+ private HttpClient Http { get; set; }
+
+ private PersonData[] data;
+
+ private SelectionType selectionType;
+
+ private PersonData selected;
+
+ private List selectedItems = new List();
+
+ protected override async Task OnInitializedAsync()
+ {
+ data = await Http.GetJsonAsync("sample-data/MOCK_DATA.json");
+ }
+
+ public class PersonData
+ {
+ public int? id { get; set; }
+ public string full_name { get; set; }
+ public string email { get; set; }
+ public bool? paid { get; set; }
+ public decimal? price { get; set; }
+ public CreditCard? cc_type { get; set; }
+ public DateTime? created_date { get; set; }
+ }
+
+ public enum CreditCard
+ {
+ none = 0,
+ [Description("MasterCard")]
+ MasterCard = 1,
+ Visa = 2
+ }
+
+ public void RowClick(PersonData data)
+ {
+ selected = data;
+ StateHasChanged();
+ }
+}
diff --git a/src/BlazorTable.Sample.Wasm/BlazorTable.Sample.Wasm.csproj b/src/BlazorTable.Sample.Wasm/BlazorTable.Sample.Wasm.csproj
index 557cff91..11e67311 100644
--- a/src/BlazorTable.Sample.Wasm/BlazorTable.Sample.Wasm.csproj
+++ b/src/BlazorTable.Sample.Wasm/BlazorTable.Sample.Wasm.csproj
@@ -3,14 +3,13 @@
netstandard2.1
3.0
- false
-
-
-
-
+
+
+
+
diff --git a/src/BlazorTable.Sample.Wasm/Program.cs b/src/BlazorTable.Sample.Wasm/Program.cs
index f88ed7f2..b0e4f033 100644
--- a/src/BlazorTable.Sample.Wasm/Program.cs
+++ b/src/BlazorTable.Sample.Wasm/Program.cs
@@ -1,6 +1,7 @@
using BlazorTable.Sample.Shared;
-using Microsoft.AspNetCore.Blazor.Hosting;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+using Microsoft.Extensions.DependencyInjection;
namespace BlazorTable.Sample.Wasm
{
@@ -11,6 +12,8 @@ public static async Task Main(string[] args)
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("app");
+ builder.Services.AddBaseAddressHttpClient();
+
await builder.Build().RunAsync();
}
}
diff --git a/src/BlazorTable.Sample.Wasm/Properties/launchSettings.json b/src/BlazorTable.Sample.Wasm/Properties/launchSettings.json
index 718fb104..c50d52ed 100644
--- a/src/BlazorTable.Sample.Wasm/Properties/launchSettings.json
+++ b/src/BlazorTable.Sample.Wasm/Properties/launchSettings.json
@@ -20,7 +20,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
- "applicationUrl": "http://localhost:51075/"
+ "applicationUrl": "http://localhost:51076/"
}
}
}
\ No newline at end of file
diff --git a/src/BlazorTable/Components/SelectionType.cs b/src/BlazorTable/Components/SelectionType.cs
new file mode 100644
index 00000000..1bb25f15
--- /dev/null
+++ b/src/BlazorTable/Components/SelectionType.cs
@@ -0,0 +1,9 @@
+namespace BlazorTable
+{
+ public enum SelectionType
+ {
+ None,
+ Single,
+ Multiple
+ }
+}
\ No newline at end of file
diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor
index 7699d483..61824a55 100644
--- a/src/BlazorTable/Components/Table.razor
+++ b/src/BlazorTable/Components/Table.razor
@@ -53,7 +53,7 @@
foreach (TableItem item in FilteredItems)
{
-
+
OnRowClickHandler(item))">
@{int locali = i;}
@if (_detailTemplate != null)
diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs
index e31fc145..b60d37df 100644
--- a/src/BlazorTable/Components/Table.razor.cs
+++ b/src/BlazorTable/Components/Table.razor.cs
@@ -322,5 +322,71 @@ public void SetDetailTemplate(DetailTemplate detailTemplate)
private RenderFragment _detailTemplate;
+ private SelectionType _selectionType;
+
+ ///
+ /// Select Type: None, Single or Multiple
+ ///
+ [Parameter]
+ public SelectionType SelectionType
+ {
+ get { return _selectionType; }
+ set
+ {
+ _selectionType = value;
+ if (_selectionType == SelectionType.None)
+ {
+ SelectedItems.Clear();
+ } else if (_selectionType == SelectionType.Single && SelectedItems.Count > 1)
+ {
+ SelectedItems.RemoveRange(1, SelectedItems.Count - 1);
+ }
+ StateHasChanged();
+ }
+ }
+
+ ///
+ /// Contains Selected Items
+ ///
+ [Parameter]
+ public List SelectedItems { get; set; } = new List();
+
+ ///
+ /// Action performed when the row is clicked.
+ ///
+ [Parameter]
+ public Action RowClickAction { get; set; }
+
+ ///
+ /// Handles the onclick action for table rows.
+ /// This allows the RowClickAction to be optional.
+ ///
+ private void OnRowClickHandler(TableItem tableItem)
+ {
+ try
+ {
+ RowClickAction?.Invoke(tableItem);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "RowClickAction threw an exception: {0}", ex);
+ }
+
+ switch (SelectionType)
+ {
+ case SelectionType.None:
+ return;
+ case SelectionType.Single:
+ SelectedItems.Clear();
+ SelectedItems.Add(tableItem);
+ break;
+ case SelectionType.Multiple:
+ if (SelectedItems.Contains(tableItem))
+ SelectedItems.Remove(tableItem);
+ else
+ SelectedItems.Add(tableItem);
+ break;
+ }
+ }
}
}
diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs
index 63ebab50..58b7703e 100644
--- a/src/BlazorTable/Interfaces/ITable.cs
+++ b/src/BlazorTable/Interfaces/ITable.cs
@@ -101,5 +101,10 @@ public interface ITable
///
///
void SetLoadingDataTemplate(LoadingDataTemplate template);
+
+ ///
+ /// Select Type: None, Single or Multiple
+ ///
+ public SelectionType SelectionType { get; set; }
}
}
\ No newline at end of file
diff --git a/src/BlazorTable/Interfaces/ITableGen.cs b/src/BlazorTable/Interfaces/ITableGen.cs
index addd64a2..681bb360 100644
--- a/src/BlazorTable/Interfaces/ITableGen.cs
+++ b/src/BlazorTable/Interfaces/ITableGen.cs
@@ -43,6 +43,16 @@ public interface ITable : ITable
///
IEnumerable FilteredItems { get; }
+ ///
+ /// Action performed when the row is clicked
+ ///
+ Action RowClickAction { get; set; }
+
+ ///
+ /// Collection of selected items
+ ///
+ List SelectedItems { get; }
+
///
/// Set the SetDetailTemplate for the table
///