Skip to content

Commit b04b6b6

Browse files
Merge pull request #938 from IgniteUI/bpachilova/disabledSummaries-samples-935
feat(grids): add disabled summaries samples
2 parents 457e55f + 33f34ee commit b04b6b6

33 files changed

+3257
-0
lines changed

Diff for: samples/grids/grid/disabled-summaries/App.razor

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
@using IgniteUI.Blazor.Controls
2+
3+
@inject IJSRuntime JS
4+
5+
<div class="container vertical ig-typography">
6+
<div class="container vertical fill">
7+
<div class="wrapper">
8+
<span class="summaries-title">Disable Summaries for Column:</span>
9+
<div class="summaries-buttons">
10+
@if (grid != null && columns?.Length > 0)
11+
{
12+
@foreach (IgbColumn column in columns)
13+
{
14+
<IgbButton Variant="ButtonVariant.Contained" class="summary-button"
15+
@onclick="() => OnDialogShow(column)">@column.Header</IgbButton>
16+
}
17+
}
18+
</div>
19+
<IgbDialog @ref="dialog" Title="@dialogTitle" CloseOnOutsideClick="true">
20+
<div class="summaries-dialog-items">
21+
@if (currentColumn != null && currentColumn.HasSummary && summaries.Count() > 0)
22+
{
23+
@foreach (var summary in this.summaries)
24+
{
25+
<IgbCheckbox Value="@summary.Key" Checked="@currentColDisabledSummaries.Contains(summary.Key)"
26+
Change="@((evt) => ToggleSummary(evt))">@summary.Value</IgbCheckbox>
27+
}
28+
}
29+
</div>
30+
<IgbButton slot="footer" Variant=@ButtonVariant.Flat Disabled="currentColDisabledSummaries.Count == summaries.Count()"
31+
@onclick="() => ToggleAllSummaries(false)">Disable All</IgbButton>
32+
<IgbButton slot="footer" Variant=@ButtonVariant.Flat Disabled="currentColDisabledSummaries.Count == 0"
33+
@onclick="() => ToggleAllSummaries(true)">Enable All</IgbButton>
34+
</IgbDialog>
35+
36+
<IgbGrid AutoGenerate="false"
37+
Name="grid"
38+
Id="grid"
39+
@ref="grid"
40+
Data="NwindData"
41+
PrimaryKey="ProductID"
42+
ColumnInitScript="ColumnInitScript">
43+
<IgbColumn Field="ProductID"
44+
Name="ProductID"
45+
Header="Product ID"
46+
HasSummary="true"
47+
@ref="productID">
48+
</IgbColumn>
49+
50+
<IgbColumn Name="ProductName"
51+
@ref="productName"
52+
Field="ProductName"
53+
Header="Product Name"
54+
HasSummary="true">
55+
</IgbColumn>
56+
57+
<IgbColumn Name="UnitPrice"
58+
@ref="unitPrice"
59+
Field="UnitPrice"
60+
Header="Unit Price"
61+
HasSummary="true">
62+
</IgbColumn>
63+
64+
<IgbColumn Name="UnitsInStock"
65+
@ref="unitsInStock"
66+
Field="UnitsInStock"
67+
Header="Units In Stock"
68+
HasSummary="true"
69+
DataType="GridColumnDataType.Number">
70+
</IgbColumn>
71+
72+
<IgbColumn Name="Discontinued"
73+
@ref="discontinued"
74+
Field="Discontinued"
75+
HasSummary="true"
76+
Header="Discontinued">
77+
</IgbColumn>
78+
79+
<IgbColumn Name="OrderDate"
80+
@ref="orderDate"
81+
Field="OrderDate"
82+
Header="Order Date"
83+
HasSummary="true"
84+
DataType="GridColumnDataType.Date">
85+
</IgbColumn>
86+
87+
</IgbGrid>
88+
</div>
89+
90+
</div>
91+
</div>
92+
93+
@code {
94+
private IgbGrid grid;
95+
private IgbColumn productID;
96+
private IgbColumn productName;
97+
private IgbColumn unitPrice;
98+
private IgbColumn unitsInStock;
99+
private IgbColumn discontinued;
100+
private IgbColumn orderDate;
101+
102+
private IgbColumn[] columns { get; set; } = [];
103+
private IgbColumn currentColumn;
104+
105+
private Dictionary<string, string> summaries = [];
106+
private List<string> currentColDisabledSummaries { get; set; } = new List<string>();
107+
108+
private IgbDialog dialog;
109+
private string dialogTitle;
110+
111+
private NwindData _nwindData = null;
112+
public NwindData NwindData
113+
{
114+
get
115+
{
116+
if (_nwindData == null)
117+
{
118+
_nwindData = new NwindData();
119+
}
120+
return _nwindData;
121+
}
122+
}
123+
124+
protected override async Task OnAfterRenderAsync(bool firstRender)
125+
{
126+
if (firstRender)
127+
{
128+
if (grid != null)
129+
{
130+
columns = new IgbColumn[] { productID, productName, unitPrice, unitsInStock, discontinued, orderDate };
131+
StateHasChanged();
132+
}
133+
}
134+
}
135+
136+
public async Task OnDialogShow(IgbColumn column)
137+
{
138+
if (this.dialog != null)
139+
{
140+
this.currentColumn = column;
141+
this.dialogTitle = "Disable Summaries for: " + column.Header;
142+
this.currentColDisabledSummaries.Clear();
143+
if (currentColumn.DisabledSummaries != null)
144+
{
145+
this.currentColDisabledSummaries = currentColumn.DisabledSummaries?.ToList();
146+
}
147+
await this.GetSummaryKeysAsync();
148+
await this.dialog.ShowAsync();
149+
}
150+
}
151+
152+
private async Task GetSummaryKeysAsync()
153+
{
154+
if (currentColumn != null && currentColumn.HasSummary)
155+
{
156+
summaries = await JS.InvokeAsync<Dictionary<string, string>>("getSummaries", currentColumn.Field);
157+
StateHasChanged();
158+
}
159+
}
160+
161+
public async Task ToggleSummary(IgbCheckboxChangeEventArgs eventArgs)
162+
{
163+
if (currentColumn != null && currentColumn.HasSummary)
164+
{
165+
string summaryKey = eventArgs.Detail.Value;
166+
if (eventArgs.Detail.Checked && !currentColDisabledSummaries.Contains(summaryKey))
167+
{
168+
currentColDisabledSummaries.Add(summaryKey);
169+
}
170+
else if (!eventArgs.Detail.Checked && currentColDisabledSummaries.Contains(summaryKey))
171+
{
172+
currentColDisabledSummaries.Remove(eventArgs.Detail.Value);
173+
}
174+
currentColumn.DisabledSummaries = currentColDisabledSummaries.ToArray();
175+
}
176+
}
177+
178+
public async Task ToggleAllSummaries(bool enable)
179+
{
180+
if (currentColumn != null && currentColumn.HasSummary)
181+
{
182+
if (enable)
183+
{
184+
currentColDisabledSummaries.Clear();
185+
}
186+
else
187+
{
188+
currentColDisabledSummaries = summaries.Keys.ToList();
189+
}
190+
currentColumn.DisabledSummaries = currentColDisabledSummaries.ToArray();
191+
}
192+
}
193+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
<AssemblyName>Infragistics.Samples</AssemblyName>
7+
<RootNamespace>Infragistics.Samples</RootNamespace>
8+
</PropertyGroup>
9+
10+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
11+
<NoWarn>1701;1702,IDE0028,BL0005,0219,CS1998</NoWarn>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="IgniteUI.Blazor" Version="24.2.85" />
16+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
17+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" />
18+
<PackageReference Include="System.Net.Http.Json" Version="9.0.0" />
19+
</ItemGroup>
20+
21+
</Project>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29613.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClientApp", "BlazorClientApp.csproj", "{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {FC52AAC8-4488-40AE-9621-75F6BA744B18}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)