diff --git a/samples/grids/grid/disabled-summaries/App.razor b/samples/grids/grid/disabled-summaries/App.razor new file mode 100644 index 0000000000..f44e149568 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/App.razor @@ -0,0 +1,198 @@ +@using IgniteUI.Blazor.Controls + +@inject IJSRuntime JS + +
+
+
+ Disable Summaries for Column: +
+ @if (grid != null && columns?.Length > 0) + { + @foreach (IgbColumn column in columns) + { + @column.Header + } + } +
+ +
+ @if (currentColumn != null && currentColumn.HasSummary && summaries.Count() > 0) + { + @foreach (var summary in this.summaries) + { + @summary.Value + } + } +
+ Disable All + Enable All +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +@code { + private IgbGrid grid; + private IgbColumn productID; + private IgbColumn productName; + private IgbColumn unitPrice; + private IgbColumn unitsInStock; + private IgbColumn discontinued; + private IgbColumn orderDate; + + private IgbColumn[] columns { get; set; } = []; + private IgbColumn currentColumn; + + private Dictionary summaries = []; + private List currentColDisabledSummaries { get; set; } = new List(); + + private IgbDialog dialog; + private string dialogTitle; + + private NwindData _nwindData = null; + public NwindData NwindData + { + get + { + if (_nwindData == null) + { + _nwindData = new NwindData(); + } + return _nwindData; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + if (grid != null) + { + columns = new IgbColumn[] { productID, productName, unitPrice, unitsInStock, discontinued, orderDate }; + StateHasChanged(); + } + } + } + + public async Task OnDialogShow(IgbColumn column) + { + if (this.dialog != null) + { + this.currentColumn = column; + this.dialogTitle = "Disable Summaries for: " + column.Header; + this.currentColDisabledSummaries.Clear(); + //this.CurrentColDisabledSummaries = currentColumn.DisabledSummaries.ToList(); //TODO + await this.GetSummaryKeysAsync(); + await this.dialog.ShowAsync(); + } + } + + private async Task GetSummaryKeysAsync() + { + if (currentColumn != null && currentColumn.HasSummary) + { + summaries = await JS.InvokeAsync>("getSummaries", currentColumn.Field); + StateHasChanged(); + } + } + + public async Task ToggleSummary(IgbCheckboxChangeEventArgs eventArgs) + { + if (currentColumn != null && currentColumn.HasSummary) + { + string summaryKey = eventArgs.Detail.Value; + if (eventArgs.Detail.Checked && !currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Add(summaryKey); + } + else if (!eventArgs.Detail.Checked && currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Remove(eventArgs.Detail.Value); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } + + public async Task ToggleAllSummaries(bool enable) + { + if (currentColumn != null && currentColumn.HasSummary) + { + if (enable) + { + currentColDisabledSummaries.Clear(); + } + else + { + currentColDisabledSummaries = summaries.Keys.ToList(); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } +} \ No newline at end of file diff --git a/samples/grids/grid/disabled-summaries/BlazorClientApp.csproj b/samples/grids/grid/disabled-summaries/BlazorClientApp.csproj new file mode 100644 index 0000000000..72fd9f896f --- /dev/null +++ b/samples/grids/grid/disabled-summaries/BlazorClientApp.csproj @@ -0,0 +1,21 @@ + + + + net9.0 + 3.0 + Infragistics.Samples + Infragistics.Samples + + + + 1701;1702,IDE0028,BL0005,0219,CS1998 + + + + + + + + + + diff --git a/samples/grids/grid/disabled-summaries/BlazorClientApp.sln b/samples/grids/grid/disabled-summaries/BlazorClientApp.sln new file mode 100644 index 0000000000..1e2eda208a --- /dev/null +++ b/samples/grids/grid/disabled-summaries/BlazorClientApp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClientApp", "BlazorClientApp.csproj", "{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC52AAC8-4488-40AE-9621-75F6BA744B18} + EndGlobalSection +EndGlobal diff --git a/samples/grids/grid/disabled-summaries/NwindData.cs b/samples/grids/grid/disabled-summaries/NwindData.cs new file mode 100644 index 0000000000..919d8bd1b5 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/NwindData.cs @@ -0,0 +1,561 @@ +using System; +using System.Collections.Generic; +public class NwindDataItem +{ + public double ProductID { get; set; } + public string ProductName { get; set; } + public double SupplierID { get; set; } + public double CategoryID { get; set; } + public string QuantityPerUnit { get; set; } + public double UnitPrice { get; set; } + public double UnitsInStock { get; set; } + public double UnitsOnOrder { get; set; } + public double ReorderLevel { get; set; } + public bool Discontinued { get; set; } + public string OrderDate { get; set; } + public double Rating { get; set; } + public List Locations { get; set; } +} +public class NwindDataItem_LocationsItem +{ + public string Shop { get; set; } + public string LastInventory { get; set; } +} + +public class NwindData + : List +{ + public NwindData() + { + this.Add(new NwindDataItem() + { + ProductID = 1, + ProductName = @"Chai", + SupplierID = 1, + CategoryID = 1, + QuantityPerUnit = @"10 boxes x 20 bags", + UnitPrice = 18, + UnitsInStock = 39, + UnitsOnOrder = 30, + ReorderLevel = 10, + Discontinued = false, + OrderDate = @"2012-02-12", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Fun-Tasty Co.", + LastInventory = @"2018-06-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 2, + ProductName = @"Chang", + SupplierID = 1, + CategoryID = 1, + QuantityPerUnit = @"24 - 12 oz bottles", + UnitPrice = 19, + UnitsInStock = 17, + UnitsOnOrder = 40, + ReorderLevel = 25, + Discontinued = true, + OrderDate = @"2003-03-17", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 3, + ProductName = @"Aniseed Syrup", + SupplierID = 1, + CategoryID = 2, + QuantityPerUnit = @"12 - 550 ml bottles", + UnitPrice = 10, + UnitsInStock = 13, + UnitsOnOrder = 70, + ReorderLevel = 25, + Discontinued = false, + OrderDate = @"2006-03-17", + Rating = 3, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Street Market", + LastInventory = @"2018-12-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"24/7 Market", + LastInventory = @"2018-11-11" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 4, + ProductName = @"Chef Antons Cajun Seasoning", + SupplierID = 2, + CategoryID = 2, + QuantityPerUnit = @"48 - 6 oz jars", + UnitPrice = 22, + UnitsInStock = 53, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2016-03-17", + Rating = 3, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Fun-Tasty Co.", + LastInventory = @"2018-06-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Street Market", + LastInventory = @"2018-12-12" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 5, + ProductName = @"Chef Antons Gumbo Mix", + SupplierID = 2, + CategoryID = 2, + QuantityPerUnit = @"36 boxes", + UnitPrice = 21.35, + UnitsInStock = 0, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = true, + OrderDate = @"2011-11-11", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 6, + ProductName = @"Grandmas Boysenberry Spread", + SupplierID = 3, + CategoryID = 2, + QuantityPerUnit = @"12 - 8 oz jars", + UnitPrice = 25, + UnitsInStock = 0, + UnitsOnOrder = 30, + ReorderLevel = 25, + Discontinued = false, + OrderDate = @"2017-12-17", + Rating = 4, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 7, + ProductName = @"Uncle Bobs Organic Dried Pears", + SupplierID = 3, + CategoryID = 7, + QuantityPerUnit = @"12 - 1 lb pkgs.", + UnitPrice = 30, + UnitsInStock = 150, + UnitsOnOrder = 30, + ReorderLevel = 10, + Discontinued = false, + OrderDate = @"2016-07-17", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Fun-Tasty Co.", + LastInventory = @"2018-06-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Street Market", + LastInventory = @"2018-12-12" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 8, + ProductName = @"Northwoods Cranberry Sauce", + SupplierID = 3, + CategoryID = 2, + QuantityPerUnit = @"12 - 12 oz jars", + UnitPrice = 40, + UnitsInStock = 6, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2018-01-17", + Rating = 4, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Fun-Tasty Co.", + LastInventory = @"2018-06-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 9, + ProductName = @"Mishi Kobe Niku", + SupplierID = 4, + CategoryID = 6, + QuantityPerUnit = @"18 - 500 g pkgs.", + UnitPrice = 97, + UnitsInStock = 29, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = true, + OrderDate = @"2010-02-17", + Rating = 4, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 10, + ProductName = @"Ikura", + SupplierID = 4, + CategoryID = 8, + QuantityPerUnit = @"12 - 200 ml jars", + UnitPrice = 31, + UnitsInStock = 31, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2008-05-17", + Rating = 3, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Wall Market", + LastInventory = @"2018-12-06" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 11, + ProductName = @"Queso Cabrales", + SupplierID = 5, + CategoryID = 4, + QuantityPerUnit = @"1 kg pkg.", + UnitPrice = 21, + UnitsInStock = 22, + UnitsOnOrder = 30, + ReorderLevel = 30, + Discontinued = false, + OrderDate = @"2009-01-17", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Fun-Tasty Co.", + LastInventory = @"2018-06-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 12, + ProductName = @"Queso Manchego La Pastora", + SupplierID = 5, + CategoryID = 4, + QuantityPerUnit = @"10 - 500 g pkgs.", + UnitPrice = 38, + UnitsInStock = 86, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2015-11-17", + Rating = 3, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 13, + ProductName = @"Konbu", + SupplierID = 6, + CategoryID = 8, + QuantityPerUnit = @"2 kg box", + UnitPrice = 6, + UnitsInStock = 24, + UnitsOnOrder = 30, + ReorderLevel = 5, + Discontinued = false, + OrderDate = @"2015-03-17", + Rating = 2, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 14, + ProductName = @"Tofu", + SupplierID = 6, + CategoryID = 7, + QuantityPerUnit = @"40 - 100 g pkgs.", + UnitPrice = 23.25, + UnitsInStock = 35, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2017-06-17", + Rating = 4, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Street Market", + LastInventory = @"2018-12-12" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 15, + ProductName = @"Genen Shouyu", + SupplierID = 6, + CategoryID = 2, + QuantityPerUnit = @"24 - 250 ml bottles", + UnitPrice = 15.5, + UnitsInStock = 39, + UnitsOnOrder = 30, + ReorderLevel = 5, + Discontinued = false, + OrderDate = @"2014-03-17", + Rating = 4, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Local Market", + LastInventory = @"2018-07-03" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Wall Market", + LastInventory = @"2018-12-06" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 16, + ProductName = @"Pavlova", + SupplierID = 7, + CategoryID = 3, + QuantityPerUnit = @"32 - 500 g boxes", + UnitPrice = 17.45, + UnitsInStock = 29, + UnitsOnOrder = 30, + ReorderLevel = 10, + Discontinued = false, + OrderDate = @"2018-03-28", + Rating = 2, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Street Market", + LastInventory = @"2018-12-12" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"24/7 Market", + LastInventory = @"2018-11-11" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 17, + ProductName = @"Alice Mutton", + SupplierID = 7, + CategoryID = 6, + QuantityPerUnit = @"20 - 1 kg tins", + UnitPrice = 39, + UnitsInStock = 0, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = true, + OrderDate = @"2015-08-17", + Rating = 2, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Farmer Market", + LastInventory = @"2018-04-04" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 18, + ProductName = @"Carnarvon Tigers", + SupplierID = 7, + CategoryID = 8, + QuantityPerUnit = @"16 kg pkg.", + UnitPrice = 62.5, + UnitsInStock = 42, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2005-09-27", + Rating = 2, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"24/7 Market", + LastInventory = @"2018-11-11" + }, + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 19, + ProductName = @"Teatime Chocolate Biscuits", + SupplierID = 8, + CategoryID = 3, + QuantityPerUnit = @"", + UnitPrice = 9.2, + UnitsInStock = 25, + UnitsOnOrder = 30, + ReorderLevel = 5, + Discontinued = false, + OrderDate = @"2001-03-17", + Rating = 2, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Local Market", + LastInventory = @"2018-07-03" + }} + + }); + this.Add(new NwindDataItem() + { + ProductID = 20, + ProductName = @"Sir Rodneys Marmalade", + SupplierID = 8, + CategoryID = 3, + QuantityPerUnit = @"4 - 100 ml jars", + UnitPrice = 4.5, + UnitsInStock = 40, + UnitsOnOrder = 30, + ReorderLevel = 0, + Discontinued = false, + OrderDate = @"2005-03-17", + Rating = 5, + Locations = new List() + { + new NwindDataItem_LocationsItem() + { + Shop = @"Super Market", + LastInventory = @"2018-09-09" + }} + + }); + } +} diff --git a/samples/grids/grid/disabled-summaries/Program.cs b/samples/grids/grid/disabled-summaries/Program.cs new file mode 100644 index 0000000000..c6da4c4ab7 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Net.Http; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Text; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using IgniteUI.Blazor.Controls; // for registering Ignite UI modules + +namespace Infragistics.Samples +{ + public class Program + { + public static async Task Main(string[] args) + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("app"); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + // registering Ignite UI modules + builder.Services.AddIgniteUIBlazor( + typeof(IgbInputModule), + typeof(IgbGridModule) + ); + await builder.Build().RunAsync(); + } + } +} diff --git a/samples/grids/grid/disabled-summaries/Properties/launchSettings.json b/samples/grids/grid/disabled-summaries/Properties/launchSettings.json new file mode 100644 index 0000000000..18bd6fb5bc --- /dev/null +++ b/samples/grids/grid/disabled-summaries/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:4200", + "sslPort": 44385 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "BlazorSamples": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:4200" + } + } +} \ No newline at end of file diff --git a/samples/grids/grid/disabled-summaries/ReadMe.md b/samples/grids/grid/disabled-summaries/ReadMe.md new file mode 100644 index 0000000000..6a9d930ad7 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/ReadMe.md @@ -0,0 +1,70 @@ + + + +This folder contains implementation of Blazor application with example of Data Summary Options feature using [Grid](https://www.infragistics.com/products/ignite-ui-blazor/blazor/components/general-getting-started.html) component. + + + + + + + View Docs + + + View Code + + + Run Sample + + + + + +## Branches + +> **_NOTE:_** You should use [master](https://github.com/IgniteUI/igniteui-blazor-examples/tree/master) branch of this repository if you want to run samples on your computer. Use the [vnext](https://github.com/IgniteUI/igniteui-blazor-examples/tree/vnext) branch only when you want to contribute new samples to this repository. + +## Setup + +- instal **.NET SDK** from this [website](https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/install) + +## Running App in Visual Studio 2019 + +NOTE: VS 2019 has better code highlighting and error detection than VS Code does. + +- open **Visual Studio 2019** as an administrator + +- open the **BlazorClientApp.sln** solution + +- right click solution and select **Restore NuGet Packages** menu item + +- click **Debug** menu and select **Start Debugging** or press **F5** key + + +## Running App in VS Code + +- open **VS Code** as an administrator + +- open this folder in **VS Code** + +- open a terminal window + +- to restore assemblies, run this command: +```dotnet restore``` + +- to run samples, run this command: +```dotnet watch run``` + +- wait for for message: +**Now listening on: http://localhost:4200** + +- open **http://localhost:4200** in your browser + + +## Resources + +- [Razor Component Models](https://www.codemag.com/article/1911052) +- [Razor Syntax](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#razor-syntax) +- [Getting reference to components](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#capture-references-to-components) diff --git a/samples/grids/grid/disabled-summaries/_Imports.razor b/samples/grids/grid/disabled-summaries/_Imports.razor new file mode 100644 index 0000000000..d27d337cb1 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/_Imports.razor @@ -0,0 +1,9 @@ +// these namespaces are global to the app +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.WebAssembly.Http +@using Microsoft.JSInterop +@using Infragistics.Samples diff --git a/samples/grids/grid/disabled-summaries/wwwroot/events.js b/samples/grids/grid/disabled-summaries/wwwroot/events.js new file mode 100644 index 0000000000..0c4cc923c4 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/wwwroot/events.js @@ -0,0 +1,66 @@ + + +class WebGridDiscontinuedSummary { + operate(data, allData, fieldName) { + const result = []; + const values = allData.map((item) => item[fieldName] ?? 0).filter((value) => value !== null); + + const discontinuedItems = allData.filter((item) => item["Discontinued"] === true); + const discontinuedValues = discontinuedItems.map((item) => item[fieldName] ?? 0).filter((value) => !isNaN(value)); + + result.push({ key: "count", label: "Count", summaryResult: values.length }); + result.push({ key: "min", label: "Min", summaryResult: values.length > 0 ? Math.min(...values) : "N/A" }); + result.push({ key: "max", label: "Max", summaryResult: values.length > 0 ? Math.max(...values) : "N/A" }); + result.push({ key: "sum", label: "Sum", summaryResult: values.reduce((a, b) => a + b, 0) }); + result.push({ + key: "average", + label: "Average", + summaryResult: values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : "N/A" + }); + result.push({ + key: "median", + label: "Median", + summaryResult: + values.length > 0 + ? (() => { + const sortedValues = values.slice().sort((a, b) => a - b); + return sortedValues.length % 2 === 0 ? (sortedValues[sortedValues.length / 2 - 1] + sortedValues[sortedValues.length / 2]) / 2 : sortedValues[Math.floor(sortedValues.length / 2)]; + })() + : "N/A" + }); + result.push({ key: "range", label: "Range", summaryResult: values.length > 0 ? Math.max(...values) - Math.min(...values) : "N/A" }); + result.push({ key: "discontinued", label: "Discontinued Products", summaryResult: discontinuedItems.length }); + result.push({ key: "totalDiscontinued", label: "Total Discontinued Items", summaryResult: discontinuedValues.length > 0 ? discontinuedValues.reduce((a, b) => a + b, 0) : 0 }); + return result; + } +} + +class DiscontinuedSummary { + operate(data, allData, fieldName) { + const result = []; + result.push({ key: "count", label: "Count", summaryResult: allData.length }); + result.push({ key: "true", label: "True", summaryResult: allData.filter((item) => item[fieldName] === true).length }); + result.push({ key: "false", label: "False", summaryResult: allData.filter((item) => item[fieldName] === false).length }); + return result; + } +} + +igRegisterScript("ColumnInitScript", (event) => { + if (event.detail.field === "UnitsInStock") { + event.detail.summaries = WebGridDiscontinuedSummary; + } else if (event.detail.field === "Discontinued") { + event.detail.summaries = DiscontinuedSummary; + } +}, false); + + +window.getSummaries = (field) => { + const grid = document.getElementById("grid"); + const col = grid.getColumnByName(field); + const summaryOperand = col?.summaries; + if (summaryOperand) { + let result = summaryOperand.operate([], grid.data, field).map(s => ({ [s.key]: s.label })); + return Object.assign({}, ...result); + } + return {}; +}; diff --git a/samples/grids/grid/disabled-summaries/wwwroot/index.css b/samples/grids/grid/disabled-summaries/wwwroot/index.css new file mode 100644 index 0000000000..485fcca6e3 --- /dev/null +++ b/samples/grids/grid/disabled-summaries/wwwroot/index.css @@ -0,0 +1,38 @@ +/* +CSS styles are loaded from the shared CSS file located at: +https://static.infragistics.com/xplatform/css/samples/ +*/ +.fill { + padding: 16px; +} + +.summaries-buttons { + margin: 1rem 0; + display: flex; + align-items: center; + flex-wrap: wrap; +} + +.summaries-title { + font-weight: bold; +} + +.summary-button { + margin-right: 1rem; +} + +igc-dialog::part(title) { + color: #1E6DFE; +} + +.summaries-dialog-items { + display: flex; + flex-direction: column; + align-items: flex-start; +} + +.summaries-dialog-items igc-checkbox { + display: flex; + flex-direction: column; + align-items: flex-start; +} \ No newline at end of file diff --git a/samples/grids/grid/disabled-summaries/wwwroot/index.html b/samples/grids/grid/disabled-summaries/wwwroot/index.html new file mode 100644 index 0000000000..390c4352ca --- /dev/null +++ b/samples/grids/grid/disabled-summaries/wwwroot/index.html @@ -0,0 +1,32 @@ + + + + + + + + + + Samples | IgniteUI for Blazor | Infragistics + + + + + + + + + + +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + + + diff --git a/samples/grids/hierarchical-grid/disabled-summaries/App.razor b/samples/grids/hierarchical-grid/disabled-summaries/App.razor new file mode 100644 index 0000000000..32f3e21bda --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/App.razor @@ -0,0 +1,261 @@ +@using IgniteUI.Blazor.Controls + +@inject IJSRuntime JS + +
+
+
+ Disable Summaries for Column: +
+ @if (hierarchicalGrid != null && columns?.Length > 0) + { + @foreach (IgbColumn column in columns) + { + @column.Header + } + } +
+ + +
+ @if (currentColumn != null && currentColumn.HasSummary && summaries.Count() > 0) + { + @foreach (var summary in this.summaries) + { + @summary.Value + } + } +
+ Disable All + Enable All +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +@code { + private IgbHierarchicalGrid hierarchicalGrid; + private IgbColumn artist; + private IgbColumn photo; + private IgbColumn debut; + private IgbColumn grammyNominations; + private IgbColumn grammyAwards; + + private IgbColumn[] columns { get; set; } = []; + private IgbColumn currentColumn; + + private Dictionary summaries = []; + private List currentColDisabledSummaries { get; set; } = new List(); + + private IgbDialog dialog; + private string dialogTitle; + + private SingersData _singersData = null; + public SingersData SingersData + { + get + { + if (_singersData == null) + { + _singersData = new SingersData(); + } + return _singersData; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + if (hierarchicalGrid != null) + { + columns = new IgbColumn[] { artist, photo, debut, grammyNominations, grammyAwards }; + StateHasChanged(); + } + } + } + + public async Task OnDialogShow(IgbColumn column) + { + if (this.dialog != null) + { + this.currentColumn = column; + this.dialogTitle = "Disable Summaries for: " + column.Header; + this.currentColDisabledSummaries.Clear(); + //this.CurrentColDisabledSummaries = currentColumn.DisabledSummaries.ToList(); //TODO + await this.GetSummaryKeysAsync(); + await this.dialog.ShowAsync(); + } + } + + private async Task GetSummaryKeysAsync() + { + if (currentColumn != null && currentColumn.HasSummary) + { + summaries = await JS.InvokeAsync>("getSummaries", currentColumn.Field); + StateHasChanged(); + } + } + + public async Task ToggleSummary(IgbCheckboxChangeEventArgs eventArgs) + { + if (currentColumn != null && currentColumn.HasSummary) + { + string summaryKey = eventArgs.Detail.Value; + if (eventArgs.Detail.Checked && !currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Add(summaryKey); + } + else if (!eventArgs.Detail.Checked && currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Remove(eventArgs.Detail.Value); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } + + public async Task ToggleAllSummaries(bool enable) + { + if (currentColumn != null && currentColumn.HasSummary) + { + if (enable) + { + currentColDisabledSummaries.Clear(); + } + else + { + currentColDisabledSummaries = summaries.Keys.ToList(); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } +} \ No newline at end of file diff --git a/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.csproj b/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.csproj new file mode 100644 index 0000000000..72fd9f896f --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.csproj @@ -0,0 +1,21 @@ + + + + net9.0 + 3.0 + Infragistics.Samples + Infragistics.Samples + + + + 1701;1702,IDE0028,BL0005,0219,CS1998 + + + + + + + + + + diff --git a/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.sln b/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.sln new file mode 100644 index 0000000000..1e2eda208a --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/BlazorClientApp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClientApp", "BlazorClientApp.csproj", "{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC52AAC8-4488-40AE-9621-75F6BA744B18} + EndGlobalSection +EndGlobal diff --git a/samples/grids/hierarchical-grid/disabled-summaries/Program.cs b/samples/grids/hierarchical-grid/disabled-summaries/Program.cs new file mode 100644 index 0000000000..56e1ae10c8 --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/Program.cs @@ -0,0 +1,28 @@ +using System; +using System.Net.Http; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Text; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using IgniteUI.Blazor.Controls; // for registering Ignite UI modules + +namespace Infragistics.Samples +{ + public class Program + { + public static async Task Main(string[] args) + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("app"); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + // registering Ignite UI modules + builder.Services.AddIgniteUIBlazor( + typeof(IgbHierarchicalGridModule) + ); + await builder.Build().RunAsync(); + } + } +} diff --git a/samples/grids/hierarchical-grid/disabled-summaries/Properties/launchSettings.json b/samples/grids/hierarchical-grid/disabled-summaries/Properties/launchSettings.json new file mode 100644 index 0000000000..18bd6fb5bc --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:4200", + "sslPort": 44385 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "BlazorSamples": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:4200" + } + } +} \ No newline at end of file diff --git a/samples/grids/hierarchical-grid/disabled-summaries/ReadMe.md b/samples/grids/hierarchical-grid/disabled-summaries/ReadMe.md new file mode 100644 index 0000000000..99123c0c0a --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/ReadMe.md @@ -0,0 +1,70 @@ + + + +This folder contains implementation of Blazor application with example of Data Summary Options feature using [Hierarchical Grid](https://www.infragistics.com/products/ignite-ui-blazor/blazor/components/general-getting-started.html) component. + + + + + + + View Docs + + + View Code + + + Run Sample + + + + + +## Branches + +> **_NOTE:_** You should use [master](https://github.com/IgniteUI/igniteui-blazor-examples/tree/master) branch of this repository if you want to run samples on your computer. Use the [vnext](https://github.com/IgniteUI/igniteui-blazor-examples/tree/vnext) branch only when you want to contribute new samples to this repository. + +## Setup + +- instal **.NET SDK** from this [website](https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/install) + +## Running App in Visual Studio 2019 + +NOTE: VS 2019 has better code highlighting and error detection than VS Code does. + +- open **Visual Studio 2019** as an administrator + +- open the **BlazorClientApp.sln** solution + +- right click solution and select **Restore NuGet Packages** menu item + +- click **Debug** menu and select **Start Debugging** or press **F5** key + + +## Running App in VS Code + +- open **VS Code** as an administrator + +- open this folder in **VS Code** + +- open a terminal window + +- to restore assemblies, run this command: +```dotnet restore``` + +- to run samples, run this command: +```dotnet watch run``` + +- wait for for message: +**Now listening on: http://localhost:4200** + +- open **http://localhost:4200** in your browser + + +## Resources + +- [Razor Component Models](https://www.codemag.com/article/1911052) +- [Razor Syntax](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#razor-syntax) +- [Getting reference to components](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#capture-references-to-components) diff --git a/samples/grids/hierarchical-grid/disabled-summaries/SingersData.cs b/samples/grids/hierarchical-grid/disabled-summaries/SingersData.cs new file mode 100644 index 0000000000..a8a55455ca --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/SingersData.cs @@ -0,0 +1,774 @@ +using System; +using System.Collections.Generic; +public class SingersDataItem +{ + public double ID { get; set; } + public string Artist { get; set; } + public string Photo { get; set; } + public double Debut { get; set; } + public double GrammyNominations { get; set; } + public double GrammyAwards { get; set; } + public bool HasGrammyAward { get; set; } + public List Tours { get; set; } + public List Albums { get; set; } +} +public class SingersDataItem_ToursItem +{ + public string Tour { get; set; } + public string StartedOn { get; set; } + public string Location { get; set; } + public string Headliner { get; set; } + public string TouredBy { get; set; } +} +public class SingersDataItem_AlbumsItem +{ + public string Album { get; set; } + public string LaunchDate { get; set; } + public double BillboardReview { get; set; } + public double USBillboard200 { get; set; } + public string Artist { get; set; } +} + +public class SingersData + : List +{ + public SingersData() + { + this.Add(new SingersDataItem() + { + ID = 0, + Artist = @"Naomí Yepes", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/naomi.jpg", + Debut = 2011, + GrammyNominations = 6, + GrammyAwards = 0, + HasGrammyAward = false, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Faithful Tour", + StartedOn = @"Sep 12", + Location = @"Worldwide", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"City Jam Sessions", + StartedOn = @"Aug 13", + Location = @"North America", + Headliner = @"YES", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Christmas NYC 2013", + StartedOn = @"Dec 13", + Location = @"United States", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Christmas NYC 2014", + StartedOn = @"Dec 14", + Location = @"North America", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Watermelon Tour", + StartedOn = @"Feb 15", + Location = @"Worldwide", + Headliner = @"YES", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Christmas NYC 2016", + StartedOn = @"Dec 16", + Location = @"United States", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"The Dragon Tour", + StartedOn = @"Feb 17", + Location = @"Worldwide", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Organic Sessions", + StartedOn = @"Aug 18", + Location = @"United States, England", + Headliner = @"YES", + TouredBy = @"Naomí Yepes" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Hope World Tour", + StartedOn = @"Mar 19", + Location = @"Worldwide", + Headliner = @"NO", + TouredBy = @"Naomí Yepes" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Initiation", + LaunchDate = @"September 3, 2013", + BillboardReview = 86, + USBillboard200 = 1, + Artist = @"Naomí Yepes" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Dream Driven", + LaunchDate = @"August 25, 2014", + BillboardReview = 81, + USBillboard200 = 1, + Artist = @"Naomí Yepes" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"The dragon journey", + LaunchDate = @"May 20, 2016", + BillboardReview = 60, + USBillboard200 = 2, + Artist = @"Naomí Yepes" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Organic me", + LaunchDate = @"August 17, 2018", + BillboardReview = 82, + USBillboard200 = 1, + Artist = @"Naomí Yepes" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Curiosity", + LaunchDate = @"December 7, 2019", + BillboardReview = 75, + USBillboard200 = 12, + Artist = @"Naomí Yepes" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 1, + Artist = @"Babila Ebwélé", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/babila.jpg", + Debut = 2009, + GrammyNominations = 0, + GrammyAwards = 11, + HasGrammyAward = true, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"The last straw", + StartedOn = @"May 09", + Location = @"Europe, Asia", + Headliner = @"NO", + TouredBy = @"Babila Ebwélé" + }, + new SingersDataItem_ToursItem() + { + Tour = @"No foundations", + StartedOn = @"Jun 04", + Location = @"United States, Europe", + Headliner = @"YES", + TouredBy = @"Babila Ebwélé" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Crazy eyes", + StartedOn = @"Jun 08", + Location = @"North America", + Headliner = @"NO", + TouredBy = @"Babila Ebwélé" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Zero gravity", + StartedOn = @"Apr 19", + Location = @"United States", + Headliner = @"NO", + TouredBy = @"Babila Ebwélé" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Battle with myself", + StartedOn = @"Mar 08", + Location = @"North America", + Headliner = @"YES", + TouredBy = @"Babila Ebwélé" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Pushing up daisies", + LaunchDate = @"May 31, 2000", + BillboardReview = 86, + USBillboard200 = 42, + Artist = @"Babila Ebwélé" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Death's dead", + LaunchDate = @"June 8, 2016", + BillboardReview = 85, + USBillboard200 = 95, + Artist = @"Babila Ebwélé" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 2, + Artist = @"Ahmad Nazeri", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/ahmad.jpg", + Debut = 2004, + GrammyNominations = 3, + GrammyAwards = 1, + HasGrammyAward = true, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Emergency", + LaunchDate = @"March 6, 2004", + BillboardReview = 98, + USBillboard200 = 69, + Artist = @"Ahmad Nazeri" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Bursting bubbles", + LaunchDate = @"April 17, 2006", + BillboardReview = 69, + USBillboard200 = 39, + Artist = @"Ahmad Nazeri" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 3, + Artist = @"Kimmy McIlmorie", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/kimmy.jpg", + Debut = 2007, + GrammyNominations = 21, + GrammyAwards = 3, + HasGrammyAward = true, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Here we go again", + LaunchDate = @"November 18, 2017", + BillboardReview = 68, + USBillboard200 = 1, + Artist = @"Kimmy McIlmorie" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 4, + Artist = @"Mar Rueda", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/mar.jpg", + Debut = 1996, + GrammyNominations = 14, + GrammyAwards = 2, + HasGrammyAward = true, + Tours = new List() + { + } + , + Albums = new List() + { + } + + }); + this.Add(new SingersDataItem() + { + ID = 5, + Artist = @"Izabella Tabakova", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/izabella.jpg", + Debut = 2017, + GrammyNominations = 7, + GrammyAwards = 11, + HasGrammyAward = true, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Final breath", + StartedOn = @"Jun 13", + Location = @"Europe", + Headliner = @"YES", + TouredBy = @"Izabella Tabakova" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Once bitten", + StartedOn = @"Dec 18", + Location = @"Australia, United States", + Headliner = @"NO", + TouredBy = @"Izabella Tabakova" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Code word", + StartedOn = @"Sep 19", + Location = @"United States, Europe", + Headliner = @"NO", + TouredBy = @"Izabella Tabakova" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Final draft", + StartedOn = @"Sep 17", + Location = @"United States, Europe", + Headliner = @"YES", + TouredBy = @"Izabella Tabakova" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Once bitten", + LaunchDate = @"July 16, 2007", + BillboardReview = 79, + USBillboard200 = 53, + Artist = @"Izabella Tabakova" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Your graciousness", + LaunchDate = @"November 17, 2004", + BillboardReview = 69, + USBillboard200 = 30, + Artist = @"Izabella Tabakova" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Dark matters", + LaunchDate = @"November 3, 2002", + BillboardReview = 79, + USBillboard200 = 85, + Artist = @"Izabella Tabakova" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 6, + Artist = @"Nguyễn Diệp Chi", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/nguyen.jpg", + Debut = 1992, + GrammyNominations = 4, + GrammyAwards = 2, + HasGrammyAward = true, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Library of liberty", + LaunchDate = @"December 22, 2003", + BillboardReview = 93, + USBillboard200 = 5, + Artist = @"Nguyễn Diệp Chi" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 7, + Artist = @"Eva Lee", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/eva.jpg", + Debut = 2008, + GrammyNominations = 2, + GrammyAwards = 0, + HasGrammyAward = false, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Just a tease", + LaunchDate = @"May 3, 2001", + BillboardReview = 91, + USBillboard200 = 29, + Artist = @"Eva Lee" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 8, + Artist = @"Siri Jakobsson", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/siri.jpg", + Debut = 1990, + GrammyNominations = 2, + GrammyAwards = 8, + HasGrammyAward = true, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Basket case", + StartedOn = @"Jan 07", + Location = @"Europe, Asia", + Headliner = @"NO", + TouredBy = @"Siri Jakobsson" + }, + new SingersDataItem_ToursItem() + { + Tour = @"The bigger fish", + StartedOn = @"Dec 07", + Location = @"United States, Europe", + Headliner = @"YES", + TouredBy = @"Siri Jakobsson" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Missed the boat", + StartedOn = @"Jun 09", + Location = @"Europe, Asia", + Headliner = @"NO", + TouredBy = @"Siri Jakobsson" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Equivalent exchange", + StartedOn = @"Feb 06", + Location = @"United States, Europe", + Headliner = @"YES", + TouredBy = @"Siri Jakobsson" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Damage control", + StartedOn = @"Oct 11", + Location = @"Australia, United States", + Headliner = @"NO", + TouredBy = @"Siri Jakobsson" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Under the bus", + LaunchDate = @"May 14, 2000", + BillboardReview = 67, + USBillboard200 = 67, + Artist = @"Siri Jakobsson" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 9, + Artist = @"Pablo Cambeiro", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/pablo.jpg", + Debut = 2011, + GrammyNominations = 5, + GrammyAwards = 0, + HasGrammyAward = false, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Beads", + StartedOn = @"May 11", + Location = @"Worldwide", + Headliner = @"NO", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Concept art", + StartedOn = @"Dec 18", + Location = @"United States", + Headliner = @"YES", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Glass shoe", + StartedOn = @"Jan 20", + Location = @"Worldwide", + Headliner = @"YES", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Pushing buttons", + StartedOn = @"Feb 15", + Location = @"Europe, Asia", + Headliner = @"NO", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Dark matters", + StartedOn = @"Jan 04", + Location = @"Australia, United States", + Headliner = @"YES", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Greener grass", + StartedOn = @"Sep 09", + Location = @"United States, Europe", + Headliner = @"NO", + TouredBy = @"Pablo Cambeiro" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Apparatus", + StartedOn = @"Nov 16", + Location = @"Europe", + Headliner = @"NO", + TouredBy = @"Pablo Cambeiro" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Fluke", + LaunchDate = @"August 4, 2017", + BillboardReview = 93, + USBillboard200 = 98, + Artist = @"Pablo Cambeiro" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Crowd control", + LaunchDate = @"August 26, 2003", + BillboardReview = 68, + USBillboard200 = 84, + Artist = @"Pablo Cambeiro" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 10, + Artist = @"Athar Malakooti", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/athar.jpg", + Debut = 2017, + GrammyNominations = 0, + GrammyAwards = 0, + HasGrammyAward = false, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Pushing up daisies", + LaunchDate = @"February 24, 2016", + BillboardReview = 74, + USBillboard200 = 77, + Artist = @"Athar Malakooti" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 11, + Artist = @"Marti Valencia", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/marti.jpg", + Debut = 2004, + GrammyNominations = 1, + GrammyAwards = 1, + HasGrammyAward = true, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Cat eat cat world", + StartedOn = @"Sep 00", + Location = @"Worldwide", + Headliner = @"YES", + TouredBy = @"Marti Valencia" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Final straw", + StartedOn = @"Sep 06", + Location = @"United States, Europe", + Headliner = @"NO", + TouredBy = @"Marti Valencia" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Nemesis", + LaunchDate = @"June 30, 2004", + BillboardReview = 94, + USBillboard200 = 9, + Artist = @"Marti Valencia" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"First chance", + LaunchDate = @"January 7, 2019", + BillboardReview = 96, + USBillboard200 = 19, + Artist = @"Marti Valencia" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"God's advocate", + LaunchDate = @"April 29, 2007", + BillboardReview = 66, + USBillboard200 = 37, + Artist = @"Marti Valencia" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 12, + Artist = @"Alicia Stanger", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/alicia.jpg", + Debut = 2010, + GrammyNominations = 1, + GrammyAwards = 0, + HasGrammyAward = false, + Tours = new List() + { + } + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Forever alone", + LaunchDate = @"November 3, 2005", + BillboardReview = 82, + USBillboard200 = 7, + Artist = @"Alicia Stanger" + }} + + }); + this.Add(new SingersDataItem() + { + ID = 13, + Artist = @"Peter Taylor", + Photo = @"https://static.infragistics.com/xplatform/images/people/names/peter.jpg", + Debut = 2005, + GrammyNominations = 0, + GrammyAwards = 2, + HasGrammyAward = true, + Tours = new List() + { + new SingersDataItem_ToursItem() + { + Tour = @"Love", + StartedOn = @"Jun 04", + Location = @"Europe, Asia", + Headliner = @"YES", + TouredBy = @"Peter Taylor" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Fault of treasures", + StartedOn = @"Oct 13", + Location = @"North America", + Headliner = @"NO", + TouredBy = @"Peter Taylor" + }, + new SingersDataItem_ToursItem() + { + Tour = @"For eternity", + StartedOn = @"Mar 05", + Location = @"United States", + Headliner = @"YES", + TouredBy = @"Peter Taylor" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Time flies", + StartedOn = @"Jun 03", + Location = @"North America", + Headliner = @"NO", + TouredBy = @"Peter Taylor" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Highest difficulty", + StartedOn = @"Nov 01", + Location = @"Worldwide", + Headliner = @"YES", + TouredBy = @"Peter Taylor" + }, + new SingersDataItem_ToursItem() + { + Tour = @"Sleeping dogs", + StartedOn = @"May 04", + Location = @"United States, Europe", + Headliner = @"NO", + TouredBy = @"Peter Taylor" + }} + , + Albums = new List() + { + new SingersDataItem_AlbumsItem() + { + Album = @"Decisions decisions", + LaunchDate = @"April 10, 2008", + BillboardReview = 85, + USBillboard200 = 35, + Artist = @"Peter Taylor" + }, + new SingersDataItem_AlbumsItem() + { + Album = @"Climate changed", + LaunchDate = @"June 20, 2015", + BillboardReview = 66, + USBillboard200 = 89, + Artist = @"Peter Taylor" + }} + + }); + } +} diff --git a/samples/grids/hierarchical-grid/disabled-summaries/_Imports.razor b/samples/grids/hierarchical-grid/disabled-summaries/_Imports.razor new file mode 100644 index 0000000000..d27d337cb1 --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/_Imports.razor @@ -0,0 +1,9 @@ +// these namespaces are global to the app +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.WebAssembly.Http +@using Microsoft.JSInterop +@using Infragistics.Samples diff --git a/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/events.js b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/events.js new file mode 100644 index 0000000000..38c0d38dce --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/events.js @@ -0,0 +1,58 @@ +class GrammySummary { + operate(data, allData, fieldName) { + const result = []; + + result.push({ + key: "count", + label: "Count", + summaryResult: allData.filter((rec) => rec["Artist"] !== undefined && rec["Artist"] !== null && rec["Artist"] !== "").length + }); + + result.push({ + key: "nominatedSingers", + label: "Nominated Singers", + summaryResult: allData.filter((rec) => rec["GrammyNominations"] > 0).length + }); + + result.push({ + key: "singersWithAwards", + label: "Singers with Awards", + summaryResult: allData.filter((rec) => rec["GrammyAwards"] > 0).length + }); + + let grammyNominations = allData.map((item) => item["GrammyNominations"] ?? 0).filter((value) => !isNaN(value)); + + result.push({ + key: "nominations", + label: "Total Nominations", + summaryResult: grammyNominations.reduce((a, b) => a + b, 0) + }); + + let grammyAwayrds = allData.map((item) => item["GrammyAwards"] ?? 0).filter((value) => !isNaN(value)); + + result.push({ + key: "awards", + label: "Total Awards", + summaryResult: grammyAwayrds.reduce((a, b) => a + b, 0) + }); + + return result; + } +} + +igRegisterScript("ColumnInitScript", (event) => { + if (event.detail.field === "Photo") { + event.detail.summaries = GrammySummary; + } +}, false); + +window.getSummaries = (field) => { + const grid = document.getElementById("hierarchicalGrid"); + const col = grid.getColumnByName(field); + const summaryOperand = col?.summaries; + if (summaryOperand) { + let result = summaryOperand.operate([], grid.data, field).map(s => ({ [s.key]: s.label })); + return Object.assign({}, ...result); + } + return {}; +}; \ No newline at end of file diff --git a/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.css b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.css new file mode 100644 index 0000000000..d8ea507dad --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.css @@ -0,0 +1,40 @@ +/* +CSS styles are loaded from the shared CSS file located at: +https://static.infragistics.com/xplatform/css/samples/ +*/ +.fill { + padding: 16px; +} + +.summaries-buttons { + margin: 1rem 0; + display: flex; + align-items: center; + flex-wrap: wrap; +} +.summaries-container { + height: 10% !important; +} + +.summaries-title { + font-weight: bold; +} + +.summary-button { + margin-right: 1rem; +} + +igc-dialog::part(title) { + color: #1E6DFE; +} + +.summaries-dialog-items { + display: flex; + flex-direction: column; + align-items: flex-start; +} +.summaries-dialog-items igc-checkbox { + display: flex; + flex-direction: column; + align-items: flex-start; +} diff --git a/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.html b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.html new file mode 100644 index 0000000000..390c4352ca --- /dev/null +++ b/samples/grids/hierarchical-grid/disabled-summaries/wwwroot/index.html @@ -0,0 +1,32 @@ + + + + + + + + + + Samples | IgniteUI for Blazor | Infragistics + + + + + + + + + + +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + + + diff --git a/samples/grids/tree-grid/disabled-summaries/App.razor b/samples/grids/tree-grid/disabled-summaries/App.razor new file mode 100644 index 0000000000..1d4ff6c76e --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/App.razor @@ -0,0 +1,214 @@ +@using IgniteUI.Blazor.Controls + +@inject IJSRuntime JS + +
+
+
+ Disable Summaries for Column: +
+ @if (treeGrid != null && columns?.Length > 0) + { + @foreach (IgbColumn column in columns) + { + @column.Header + } + } +
+ +
+ @if (currentColumn != null && currentColumn.HasSummary && summaries.Count() > 0) + { + @foreach (var summary in this.summaries) + { + @summary.Value + } + } +
+ Disable All + Enable All +
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +@code { + private IgbTreeGrid treeGrid; + private IgbColumn orderID; + private IgbColumn orderProduct; + private IgbColumn units; + private IgbColumn unitPrice; + private IgbColumn price; + private IgbColumn delivered; + private IgbColumn orderDate; + + private IgbColumn[] columns { get; set; } = []; + private IgbColumn currentColumn; + + private Dictionary summaries = []; + private List currentColDisabledSummaries { get; set; } = new List(); + + private IgbDialog dialog; + private string dialogTitle; + + private OrdersTreeData _ordersTreeData = null; + public OrdersTreeData OrdersTreeData + { + get + { + if (_ordersTreeData == null) + { + _ordersTreeData = new OrdersTreeData(); + } + return _ordersTreeData; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + if (treeGrid != null) + { + columns = new IgbColumn[] { orderID, orderProduct, unitPrice, price, delivered, orderDate }; + StateHasChanged(); + } + } + } + + public async Task OnDialogShow(IgbColumn column) + { + if (this.dialog != null) + { + this.currentColumn = column; + this.dialogTitle = "Disable Summaries for: " + column.Header; + this.currentColDisabledSummaries.Clear(); + //this.CurrentColDisabledSummaries = currentColumn.DisabledSummaries.ToList(); //TODO + await this.GetSummaryKeysAsync(); + await this.dialog.ShowAsync(); + } + } + + private async Task GetSummaryKeysAsync() + { + if (currentColumn != null && currentColumn.HasSummary) + { + summaries = await JS.InvokeAsync>("getSummaries", currentColumn.Field); + StateHasChanged(); + } + } + + public async Task ToggleSummary(IgbCheckboxChangeEventArgs eventArgs) + { + if (currentColumn != null && currentColumn.HasSummary) + { + string summaryKey = eventArgs.Detail.Value; + if (eventArgs.Detail.Checked && !currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Add(summaryKey); + } + else if (!eventArgs.Detail.Checked && currentColDisabledSummaries.Contains(summaryKey)) + { + currentColDisabledSummaries.Remove(eventArgs.Detail.Value); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } + + public async Task ToggleAllSummaries(bool enable) + { + if (currentColumn != null && currentColumn.HasSummary) + { + if (enable) + { + currentColDisabledSummaries.Clear(); + } + else + { + currentColDisabledSummaries = summaries.Keys.ToList(); + } + foreach (string key in currentColDisabledSummaries) + { + Console.WriteLine(key); + } + //currentColumn.DisabledSummaries = CurrentColDisabledSummaries.ToArray(); //TODO + } + } +} \ No newline at end of file diff --git a/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.csproj b/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.csproj new file mode 100644 index 0000000000..72fd9f896f --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.csproj @@ -0,0 +1,21 @@ + + + + net9.0 + 3.0 + Infragistics.Samples + Infragistics.Samples + + + + 1701;1702,IDE0028,BL0005,0219,CS1998 + + + + + + + + + + diff --git a/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.sln b/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.sln new file mode 100644 index 0000000000..1e2eda208a --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/BlazorClientApp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClientApp", "BlazorClientApp.csproj", "{F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F69CC3F0-BCD1-4CE6-9F39-CBED14E7FA78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC52AAC8-4488-40AE-9621-75F6BA744B18} + EndGlobalSection +EndGlobal diff --git a/samples/grids/tree-grid/disabled-summaries/OrdersTreeData.cs b/samples/grids/tree-grid/disabled-summaries/OrdersTreeData.cs new file mode 100644 index 0000000000..98ad2eed69 --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/OrdersTreeData.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +public class OrdersTreeDataItem +{ + public double ID { get; set; } + public double ParentID { get; set; } + public string Name { get; set; } + public string Category { get; set; } + public string OrderDate { get; set; } + public double Units { get; set; } + public double UnitPrice { get; set; } + public double Price { get; set; } + public bool Delivered { get; set; } +} + +public class OrdersTreeData + : List +{ + public OrdersTreeData() + { + this.Add(new OrdersTreeDataItem() + { + ID = 1, + ParentID = -1, + Name = @"Order 1", + Category = @"", + OrderDate = @"2010-02-17", + Units = 1844, + UnitPrice = 3.73, + Price = 6884.38, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 101, + ParentID = 1, + Name = @"Chocolate Chip Cookies", + Category = @"Cookies", + OrderDate = @"2010-02-17", + Units = 834, + UnitPrice = 3.59, + Price = 2994.06, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 102, + ParentID = 1, + Name = @"Red Apples", + Category = @"Fruit", + OrderDate = @"2010-02-17", + Units = 371, + UnitPrice = 3.66, + Price = 1357.86, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 103, + ParentID = 1, + Name = @"Butter", + Category = @"Diary", + OrderDate = @"2010-02-17", + Units = 260, + UnitPrice = 3.45, + Price = 897, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 104, + ParentID = 1, + Name = @"Potato Chips", + Category = @"Snack", + OrderDate = @"2010-02-17", + Units = 118, + UnitPrice = 1.96, + Price = 231.28, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 105, + ParentID = 1, + Name = @"Orange Juice", + Category = @"Beverages", + OrderDate = @"2010-02-17", + Units = 261, + UnitPrice = 5.38, + Price = 1404.18, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 2, + ParentID = -1, + Name = @"Order 2", + Category = @"", + OrderDate = @"2022-05-27", + Units = 1831, + UnitPrice = 8.23, + Price = 15062.77, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 201, + ParentID = 2, + Name = @"Frozen Shrimps", + Category = @"Seafood", + OrderDate = @"2022-05-27", + Units = 120, + UnitPrice = 20.45, + Price = 2454, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 202, + ParentID = 2, + Name = @"Ice Tea", + Category = @"Beverages", + OrderDate = @"2022-05-27", + Units = 840, + UnitPrice = 7, + Price = 5880, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 203, + ParentID = 2, + Name = @"Fresh Cheese", + Category = @"Diary", + OrderDate = @"2022-05-27", + Units = 267, + UnitPrice = 16.55, + Price = 4418.85, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 204, + ParentID = 2, + Name = @"Carrots", + Category = @"Vegetables", + OrderDate = @"2022-05-27", + Units = 360, + UnitPrice = 2.77, + Price = 997.2, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 205, + ParentID = 2, + Name = @"Apple Juice", + Category = @"Beverages", + OrderDate = @"2022-05-27", + Units = 244, + UnitPrice = 5.38, + Price = 1312.72, + Delivered = false + }); + this.Add(new OrdersTreeDataItem() + { + ID = 3, + ParentID = -1, + Name = @"Order 3", + Category = @"", + OrderDate = @"2022-08-04", + Units = 1972, + UnitPrice = 3.47, + Price = 6849.18, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 301, + ParentID = 3, + Name = @"Skimmed Milk 1L", + Category = @"Diary", + OrderDate = @"2022-08-04", + Units = 1028, + UnitPrice = 3.56, + Price = 3659.68, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 302, + ParentID = 3, + Name = @"Bananas 5 Pack", + Category = @"Fruit", + OrderDate = @"2022-08-04", + Units = 370, + UnitPrice = 6.36, + Price = 2353.2, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 303, + ParentID = 3, + Name = @"Cauliflower", + Category = @"Vegetables", + OrderDate = @"2022-08-04", + Units = 283, + UnitPrice = 0.95, + Price = 268.85, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 304, + ParentID = 3, + Name = @"White Chocolate Cookies", + Category = @"Cookies", + OrderDate = @"2022-08-04", + Units = 291, + UnitPrice = 1.95, + Price = 567.45, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 4, + ParentID = -1, + Name = @"Order 4", + Category = @"", + OrderDate = @"2023-01-04", + Units = 1065, + UnitPrice = 5.56, + Price = 5923.5, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 401, + ParentID = 4, + Name = @"Mini Milk Chocolate Cookie Bites", + Category = @"Cookies", + OrderDate = @"2023-01-04", + Units = 68, + UnitPrice = 2.25, + Price = 153, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 402, + ParentID = 4, + Name = @"Wild Salmon Fillets", + Category = @"Seafood", + OrderDate = @"2023-01-04", + Units = 320, + UnitPrice = 16.15, + Price = 5168, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 403, + ParentID = 4, + Name = @"Diet Lemonade", + Category = @"Beverages", + OrderDate = @"2023-01-04", + Units = 437, + UnitPrice = 0.5, + Price = 218.5, + Delivered = true + }); + this.Add(new OrdersTreeDataItem() + { + ID = 404, + ParentID = 4, + Name = @"Potatoes", + Category = @"Vegetables", + OrderDate = @"2023-01-04", + Units = 240, + UnitPrice = 1.6, + Price = 384, + Delivered = true + }); + } +} diff --git a/samples/grids/tree-grid/disabled-summaries/Program.cs b/samples/grids/tree-grid/disabled-summaries/Program.cs new file mode 100644 index 0000000000..9b523f6a4b --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Net.Http; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Text; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using IgniteUI.Blazor.Controls; // for registering Ignite UI modules + +namespace Infragistics.Samples +{ + public class Program + { + public static async Task Main(string[] args) + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("app"); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + // registering Ignite UI modules + builder.Services.AddIgniteUIBlazor( + typeof(IgbInputModule), + typeof(IgbTreeGridModule) + ); + await builder.Build().RunAsync(); + } + } +} diff --git a/samples/grids/tree-grid/disabled-summaries/Properties/launchSettings.json b/samples/grids/tree-grid/disabled-summaries/Properties/launchSettings.json new file mode 100644 index 0000000000..18bd6fb5bc --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:4200", + "sslPort": 44385 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "BlazorSamples": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:4200" + } + } +} \ No newline at end of file diff --git a/samples/grids/tree-grid/disabled-summaries/ReadMe.md b/samples/grids/tree-grid/disabled-summaries/ReadMe.md new file mode 100644 index 0000000000..479e18ccb8 --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/ReadMe.md @@ -0,0 +1,70 @@ + + + +This folder contains implementation of Blazor application with example of Data Summary Options feature using [Tree Grid](https://www.infragistics.com/products/ignite-ui-blazor/blazor/components/general-getting-started.html) component. + + + + + + + View Docs + + + View Code + + + Run Sample + + + + + +## Branches + +> **_NOTE:_** You should use [master](https://github.com/IgniteUI/igniteui-blazor-examples/tree/master) branch of this repository if you want to run samples on your computer. Use the [vnext](https://github.com/IgniteUI/igniteui-blazor-examples/tree/vnext) branch only when you want to contribute new samples to this repository. + +## Setup + +- instal **.NET SDK** from this [website](https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/install) + +## Running App in Visual Studio 2019 + +NOTE: VS 2019 has better code highlighting and error detection than VS Code does. + +- open **Visual Studio 2019** as an administrator + +- open the **BlazorClientApp.sln** solution + +- right click solution and select **Restore NuGet Packages** menu item + +- click **Debug** menu and select **Start Debugging** or press **F5** key + + +## Running App in VS Code + +- open **VS Code** as an administrator + +- open this folder in **VS Code** + +- open a terminal window + +- to restore assemblies, run this command: +```dotnet restore``` + +- to run samples, run this command: +```dotnet watch run``` + +- wait for for message: +**Now listening on: http://localhost:4200** + +- open **http://localhost:4200** in your browser + + +## Resources + +- [Razor Component Models](https://www.codemag.com/article/1911052) +- [Razor Syntax](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#razor-syntax) +- [Getting reference to components](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#capture-references-to-components) diff --git a/samples/grids/tree-grid/disabled-summaries/_Imports.razor b/samples/grids/tree-grid/disabled-summaries/_Imports.razor new file mode 100644 index 0000000000..d27d337cb1 --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/_Imports.razor @@ -0,0 +1,9 @@ +// these namespaces are global to the app +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.WebAssembly.Http +@using Microsoft.JSInterop +@using Infragistics.Samples diff --git a/samples/grids/tree-grid/disabled-summaries/wwwroot/events.js b/samples/grids/tree-grid/disabled-summaries/wwwroot/events.js new file mode 100644 index 0000000000..3127ea6a6f --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/wwwroot/events.js @@ -0,0 +1,99 @@ +class UnitsSummary { + operate(data, allData, fieldName) { + const result = []; + + const values = allData.map((rec) => rec[fieldName]).filter((value) => value !== undefined && value !== null); + const totalSum = values.reduce((sum, value) => sum + value, 0); + const sortedValues = values.slice().sort((a, b) => a - b); + const deliveredValues = allData + .filter((rec) => rec["Delivered"]) + .map((rec) => rec[fieldName]) + .filter((value) => value !== undefined && value !== null); + + result.push({ + key: "count", + label: "Count", + summaryResult: allData.length + }); + + result.push({ + key: "min", + label: "Min", + summaryResult: values.length > 0 ? Math.min(...values) : "N/A" + }); + + result.push({ + key: "max", + label: "Max", + summaryResult: values.length > 0 ? Math.max(...values) : "N/A" + }); + + result.push({ + key: "sum", + label: "Sum", + summaryResult: totalSum + }); + + result.push({ + key: "average", + label: "Average", + summaryResult: values.length > 0 ? totalSum / values.length : "N/A" + }); + + result.push({ + key: "totalDelivered", + label: "Total Units Delivered", + summaryResult: deliveredValues.length > 0 ? deliveredValues.reduce((sum, value) => sum + value, 0) : "N/A" + }); + + result.push({ + key: "medianUnits", + label: "Median Units", + summaryResult: + values.length > 0 + ? (() => { + const mid = Math.floor(sortedValues.length / 2); + return sortedValues.length % 2 !== 0 ? sortedValues[mid] : (sortedValues[mid - 1] + sortedValues[mid]) / 2; + })() + : "N/A" + }); + + result.push({ + key: "uniqueCount", + label: "Count of Unique Unit Values", + summaryResult: values.length > 0 ? new Set(values).size : "N/A" + }); + + result.push({ + key: "maxDifference", + label: "Max Difference Between Units", + summaryResult: + values.length > 1 + ? values.reduce((maxDiff, value, idx, arr) => { + if (idx === 0) return maxDiff; + const diff = Math.abs(value - arr[idx - 1]); + return Math.max(maxDiff, diff); + }, 0) + : "N/A" + }); + + return result; + } +} + +igRegisterScript("ColumnInitScript", (event) => { + if (event.detail.field === "Units") { + event.detail.summaries = UnitsSummary; + } +}, false); + +window.getSummaries = (field) => { + const grid = document.getElementById("treeGrid"); + const col = grid.getColumnByName(field); + const summaryOperand = col?.summaries; + if (summaryOperand) { + let result = summaryOperand.operate([], grid.data, field).map(s => ({ [s.key]: s.label })); + return Object.assign({}, ...result); + } + return {}; +}; diff --git a/samples/grids/tree-grid/disabled-summaries/wwwroot/index.css b/samples/grids/tree-grid/disabled-summaries/wwwroot/index.css new file mode 100644 index 0000000000..01ef6e3ab5 --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/wwwroot/index.css @@ -0,0 +1,38 @@ +/* +CSS styles are loaded from the shared CSS file located at: +https://static.infragistics.com/xplatform/css/samples/ +*/ +.fill { + padding: 16px; +} + +.summaries-buttons { + margin: 1rem 0; + display: flex; + align-items: center; + flex-wrap: wrap; +} + +.summaries-title { + font-weight: bold; +} + +.summary-button { + margin-right: 1rem; +} + +igc-dialog::part(title) { + color: #1E6DFE; +} + +.summaries-dialog-items { + display: flex; + flex-direction: column; + align-items: flex-start; +} + + .summaries-dialog-items igc-checkbox { + display: flex; + flex-direction: column; + align-items: flex-start; + } diff --git a/samples/grids/tree-grid/disabled-summaries/wwwroot/index.html b/samples/grids/tree-grid/disabled-summaries/wwwroot/index.html new file mode 100644 index 0000000000..6ea07bab27 --- /dev/null +++ b/samples/grids/tree-grid/disabled-summaries/wwwroot/index.html @@ -0,0 +1,33 @@ + + + + + + + + + + Samples | IgniteUI for Blazor | Infragistics + + + + + + + + + + +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + + + +