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

WIP: PivotGrid #3214

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions Blazorise.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{50E48B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazorise.Shared", "Shared\Blazorise.Shared\Blazorise.Shared.csproj", "{692A8724-CF60-4A33-921D-EB8F3A60A2CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazorise.PivotGrid", "Source\Extensions\Blazorise.PivotGrid\Blazorise.PivotGrid.csproj", "{D023DEA5-D026-45F8-A71F-54DE27C6C5D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -244,6 +246,10 @@ Global
{692A8724-CF60-4A33-921D-EB8F3A60A2CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692A8724-CF60-4A33-921D-EB8F3A60A2CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692A8724-CF60-4A33-921D-EB8F3A60A2CF}.Release|Any CPU.Build.0 = Release|Any CPU
{D023DEA5-D026-45F8-A71F-54DE27C6C5D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D023DEA5-D026-45F8-A71F-54DE27C6C5D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D023DEA5-D026-45F8-A71F-54DE27C6C5D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D023DEA5-D026-45F8-A71F-54DE27C6C5D1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -287,6 +293,7 @@ Global
{224FDE0F-A04B-4BF4-8D14-E0D7871B0F1E} = {73CD9574-5204-442D-A67C-CA7B038057C2}
{CCA627E3-633E-4F00-854C-F028AB298CF5} = {C2D0A89F-530E-413F-9D0E-9EE2129A2275}
{692A8724-CF60-4A33-921D-EB8F3A60A2CF} = {50E48BFC-84F3-480A-BAE7-201E72CE94B9}
{D023DEA5-D026-45F8-A71F-54DE27C6C5D1} = {9731051E-0AA7-411E-A76A-987854F034DA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {205B3EA4-470F-45DA-911E-346AF7D0A9A5}
Expand Down
1 change: 1 addition & 0 deletions Demos/Blazorise.Demo/Blazorise.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Components\Blazorise.Components.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.DataGrid\Blazorise.DataGrid.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Markdown\Blazorise.Markdown.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.PivotGrid\Blazorise.PivotGrid.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.RichTextEdit\Blazorise.RichTextEdit.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Sidebar\Blazorise.Sidebar.csproj" />
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Snackbar\Blazorise.Snackbar.csproj" />
Expand Down
49 changes: 24 additions & 25 deletions Demos/Blazorise.Demo/Pages/Dashboard.razor
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
@page "/"
@inject IVersionProvider VersionProvider
<Heading Size="HeadingSize.Is1" Margin="Margin.Is3.FromBottom">Blazorise</Heading>

<Paragraph>
Blazorise is a component library built on top of Blazor and CSS frameworks like <Anchor To="https://getbootstrap.com/" Target="Target.Blank">Bootstrap</Anchor>, <Anchor To="https://bulma.io/" Target="Target.Blank">Bulma</Anchor>, <Anchor To="https://ant.design/" Target="Target.Blank">Ant Design</Anchor>, and <Anchor To="http://daemonite.github.io/material/" Target="Target.Blank">Material</Anchor>. It can be used to build responsive, single-page web applications.
</Paragraph>
<PivotGrid TItem="Employee" Data="inMemoryData">
<PivotGridColumns>
<PivotGridColumn Caption="Year"></PivotGridColumn>
<PivotGridColumn Caption="Quarter"></PivotGridColumn>
</PivotGridColumns>
<PivotGridValues>
<PivotGridValue Caption="Quantity"></PivotGridValue>
<PivotGridValue Caption="Amount"></PivotGridValue>
</PivotGridValues>
<PivotGridRows>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use-case for rows? Why do we need to define them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now what you wanted to do. It has an API similar to the SF.

Copy link
Contributor Author

@David-Moreira David-Moreira Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the same uses cases as this API
enum Area {
Row, // it will be shown in a row header and grouped by this => PivotGridRow
Column, // it will be shown as a regular column, just like DataGrid => PivotGridColumn
Data, // it will be used for the summary => PivotGridValue
}

<PivotGridRow></PivotGridRow>
<PivotGridRow></PivotGridRow>
</PivotGridRows>

<Alert Color="Color.Info" Visible="true">
<Heading Size="HeadingSize.Is4" TextColor="TextColor.Success">
Note:
</Heading>
<Paragraph>
This is a demo application for Blazorise used to show basic example for most of the components and extensions.
</Paragraph>
<Paragraph>
Full source code for this demo can be found on <Anchor To="https://github.com/Megabit/Blazorise/tree/master/Demos/Blazorise.Demo" Target="Target.Blank">GitHub</Anchor>.
</Paragraph>
<Paragraph>
If you wish to learn more about Blazorise please go to the official <Anchor To="https://blazorise.com/docs/" Target="Target.Blank">documentation</Anchor>.
</Paragraph>
</Alert>
</PivotGrid>
@code {
[Inject] EmployeeData EmployeeData { get; set; }

<Paragraph>
On the left sidebar you can see the Blazorise components and extensions in action.
</Paragraph>
<br />
<Paragraph>
<Strong> Demo application for</Strong>: Blazorise @($"v{VersionProvider.MilestoneVersion}")
</Paragraph>
private IEnumerable<Employee> inMemoryData;

protected override async Task OnInitializedAsync()
{
inMemoryData = (await EmployeeData.GetDataAsync().ConfigureAwait(false)).Take(25);
await base.OnInitializedAsync();
}
}
3 changes: 2 additions & 1 deletion Demos/Blazorise.Demo/Pages/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@layout MainLayout
@using Blazorise.Shared.Data
@using Blazorise.Shared.Models
@using Blazorise.Shared.Models
@using Blazorise.PivotGrid
1 change: 1 addition & 0 deletions Demos/Blazorise.Demo/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@using Blazorise.Charts
@using Blazorise.Charts.Streaming
@using Blazorise.DataGrid
@using Blazorise.PivotGrid
@using Blazorise.Sidebar
@using Blazorise.Snackbar
@using Blazorise.TreeView
Expand Down
10 changes: 6 additions & 4 deletions Documentation/Blazorise.Docs/Models/Snippets.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3857,8 +3857,10 @@ private bool RowSelectableHandler( RowSelectableEventArgs<Employee> rowSelectabl
Data=""@employeeList""
@bind-SelectedRow=""@selectedEmployee""
Responsive
Virtualize
VirtualizeOptions=""@(new() { DataGridHeight = ""250px""})"">
ShowPager
FixedHeader
FixedHeaderDataGridMaxHeight=""250px""
PageSize=""50"">
<DataGridCommandColumn TItem=""Employee"" />
<DataGridColumn TItem=""Employee"" Field=""@nameof(Employee.Id)"" Caption=""#"" Sortable=""false"" />
<DataGridColumn TItem=""Employee"" Field=""@nameof(Employee.FirstName)"" Caption=""First Name"" Editable=""true"" />
Expand All @@ -3885,10 +3887,10 @@ protected override async Task OnInitializedAsync()
}

private Task ScrollToRow()
=> dataGridRef.ScrollToRow(1).AsTask();
=> dataGridRef.ScrollToRow(30).AsTask();

private Task ScrollToPixels()
=> dataGridRef.ScrollToPixels(250).AsTask();
=> dataGridRef.ScrollToPixels(500).AsTask();
}";

public const string DataGridSelectingExample = @"<DataGrid TItem=""Employee""
Expand Down
1 change: 0 additions & 1 deletion Documentation/Blazorise.Docs/NewFilesToBuild.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
C:\Users\david\source\repos\_Work\Blazorise\Documentation\Blazorise.Docs\Pages\Docs\Extensions\DataGrid\Code\DataGridScrollToExampleCode.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<span class="htmlAttributeName">Data</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>employeeList</span><span class="quot">&quot;</span>
<span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-SelectedRow</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="sharpVariable"><span class="atSign">&#64;</span>selectedEmployee</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">Responsive</span>
<span class="htmlAttributeName">Virtualize</span>
<span class="htmlAttributeName">VirtualizeOptions</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>(new() { DataGridHeight = &quot;250px&quot;})</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlAttributeName">ShowPager</span>
<span class="htmlAttributeName">FixedHeader</span>
<span class="htmlAttributeName">FixedHeaderDataGridMaxHeight</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">250px</span><span class="quot">&quot;</span>
<span class="htmlAttributeName">PageSize</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">50</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DataGridCommandColumn</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Employee</span><span class="quot">&quot;</span> <span class="htmlTagDelimiter">/&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DataGridColumn</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Employee</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Field</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>nameof(Employee.Id)</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Caption</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">#</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Sortable</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="keyword">false</span><span class="quot">&quot;</span> <span class="htmlTagDelimiter">/&gt;</span>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DataGridColumn</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Employee</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Field</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>nameof(Employee.FirstName)</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Caption</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">First Name</span><span class="quot">&quot;</span> <span class="htmlAttributeName">Editable</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="keyword">true</span><span class="quot">&quot;</span> <span class="htmlTagDelimiter">/&gt;</span>
Expand Down Expand Up @@ -37,10 +39,10 @@
}

<span class="keyword">private</span> Task ScrollToRow()
=&gt; dataGridRef.ScrollToRow(<span class="number">1</span>).AsTask();
=&gt; dataGridRef.ScrollToRow(<span class="number">30</span>).AsTask();

<span class="keyword">private</span> Task ScrollToPixels()
=&gt; dataGridRef.ScrollToPixels(<span class="number">250</span>).AsTask();
=&gt; dataGridRef.ScrollToPixels(<span class="number">500</span>).AsTask();
}
</pre></div>
</div>
27 changes: 27 additions & 0 deletions Source/Extensions/Blazorise.PivotGrid/Blazorise.PivotGrid.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<Import Project="..\..\..\Build\Blazorise.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageTags>blazorise blazor components pivotgrid</PackageTags>
</PropertyGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Blazorise\Blazorise.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\LICENSE.md" Pack="true" Visible="false" PackagePath="" />
<None Include="..\..\..\NuGet\Blazorise.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
</Project>
81 changes: 81 additions & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGrid.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@typeparam TItem
@attribute [CascadingTypeParameter(nameof(TItem))]
<CascadingValue Value="this" IsFixed>
@PivotGridColumns
@PivotGridRows
@PivotGridValues
</CascadingValue>

@*Example: *@
<table>
<thead>
<tr>
<th>...</th>
<th>(Col Year)2021 - click expands into more trs with detail</th>
<th>(Col Year)2022 - click expands into more trs with detail</th>
</tr>
<tr>
<th>...</th>
<th>(Data)Amount</th>
<th>(Data)Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>(row) Africa - click expands into more trs with detail</td>
<td>100</td>
<td>5</td>
</tr>
<tr>
<td>(row) Asia - click expands into more trs with detail</td>
<td>3000</td>
<td>9</td>
</tr>
</tbody>
</table>

<Table>
<TableHeader>
@*Cols*@
<TableRow>
<TableHeaderCell></TableHeaderCell>
@foreach (var colGroup in colGroups)
{
<TableHeaderCell ColumnSpan="Values.Count">
@colGroup
</TableHeaderCell>
}
</TableRow>

@*Values*@
<TableRow>
<TableHeaderCell></TableHeaderCell>
@for (var i = 0; i < colGroups.Count; i++)
{
@foreach (var value in Values)
{
<TableHeaderCell>
@value.Caption
</TableHeaderCell>
}
}
</TableRow>
</TableHeader>
<TableBody>
@foreach (var rowGroup in rowGroups)
{
<TableRow>
<TableRowCell>@rowGroup</TableRowCell>
@*Iterate data vs no. columns?*@
</TableRow>
}

</TableBody>
<TableFooter>

</TableFooter>
</Table>
@code {
private List<string> rowGroups = new() { "Africa", "Asia" };
private List<string> colGroups = new() { "2021", "2022" };
}
63 changes: 63 additions & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGrid.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

namespace Blazorise.PivotGrid
{
public partial class PivotGrid<TItem> : ComponentBase
{

[Parameter]
public IEnumerable<TItem> Data { get; set; }


protected List<PivotGridValue<TItem>> Values { get; set; } = new();
protected List<PivotGridColumn<TItem>> Columns { get; set; } = new();
protected List<PivotGridRow<TItem>> Rows { get; set; } = new();


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

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

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



public void AddColumn( PivotGridColumn<TItem> column )
{
Columns.Add( column );
}

public bool RemoveColumn( PivotGridColumn<TItem> column )
{
return Columns.Remove( column );
}

public void AddRow( PivotGridRow<TItem> row )
{
Rows.Add( row );
}

public bool RemoveRow( PivotGridRow<TItem> row )
{
return Rows.Remove( row );
}

public void AddValue( PivotGridValue<TItem> value )
{
Values.Add( value );
}

public bool RemoveValue( PivotGridValue<TItem> value )
{
return Values.Remove( value );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@typeparam TItem
28 changes: 28 additions & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGridColumn.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

namespace Blazorise.PivotGrid
{
public partial class PivotGridColumn<TItem> : ComponentBase
{

[CascadingParameter]
public PivotGrid<TItem> ParentPivotGrid { get; set; }

[Parameter]
public string Field { get; set; }

[Parameter]
public string Caption { get; set; }

protected override void OnInitialized()
{
base.OnInitialized();
ParentPivotGrid?.AddColumn( this );
}
}
}
1 change: 1 addition & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGridRow.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@typeparam TItem
25 changes: 25 additions & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGridRow.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

namespace Blazorise.PivotGrid
{
public partial class PivotGridRow<TItem> : ComponentBase
{

[CascadingParameter]
public PivotGrid<TItem> ParentPivotGrid { get; set; }

[Parameter]
public string Field { get; set; }

protected override void OnInitialized()
{
base.OnInitialized();
ParentPivotGrid?.AddRow( this );
}
}
}
1 change: 1 addition & 0 deletions Source/Extensions/Blazorise.PivotGrid/PivotGridValue.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@typeparam TItem
Loading