-
Notifications
You must be signed in to change notification settings - Fork 462
[DataGrid] Add Hierarchical DataGrid functionality #4484
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
967e593
Add HierarchicalGridItem with sample
vnbaaij 54b27d7
- Add Org Chart demo and supporting code
vnbaaij 3aa79ed
Merge branch 'dev' into users/vnbaaij/hierarchical-datagrid
vnbaaij c3c8b5f
RTL and row size fixes
vnbaaij 7a52b60
rtl/ltr optimizations
vnbaaij f581937
Fix UpdateHidden issue
vnbaaij 18cdf94
Typo
vnbaaij c6bb77c
Improve the DataGrid js script
vnbaaij 2b8a831
Merge branch 'dev' into users/vnbaaij/hierarchical-datagrid
vnbaaij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
examples/Demo/Shared/Pages/DataGrid/Examples/DataGridHierarchical.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| @using Microsoft.FluentUI.AspNetCore.Components | ||
| @using FluentUI.Demo.Shared.SampleData | ||
|
|
||
| <style> | ||
| :root { | ||
| --datagrid-hover-color: lightyellow; | ||
| } | ||
|
|
||
| .fluent-data-grid { | ||
| --fluent-data-grid-resize-handle-color: var(--neutral-stroke-rest) !important; | ||
| } | ||
|
|
||
| .flag { | ||
| height: 1rem; | ||
| border: 1px solid var(--neutral-layer-3); | ||
| } | ||
|
|
||
| td { | ||
| height: 38px!important | ||
| } | ||
| </style> | ||
|
|
||
| <FluentDataGrid Items="@items.Where(i => !i.IsHidden).AsQueryable()" ShowHover="true" ResizableColumns="true"> | ||
| <TemplateColumn Title="Name" HierarchicalToggle="true"> | ||
| @if (context.Item.ContinentCode != null) | ||
| { | ||
| <img class="flag" src="_content/FluentUI.Demo.Shared/flags/@(context.Item.Code).svg" alt="Flag of @(context.Item.Code)" /> | ||
| } | ||
| @context.Item.Name | ||
| </TemplateColumn> | ||
| <PropertyColumn Title="Gold" Property="@(i => i.Item.Medals.Gold)" /> | ||
| <PropertyColumn Title="Silver" Property="@(i => i.Item.Medals.Silver)" /> | ||
| <PropertyColumn Title="Bronze" Property="@(i => i.Item.Medals.Bronze)" /> | ||
| <PropertyColumn Title="Total" Property="@(i => i.Item.Medals.Total)" /> | ||
|
|
||
| </FluentDataGrid> | ||
|
|
||
| @code { | ||
| List<OlympicGridItem> items = new(); | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| foreach (var continent in DataSource.Continents) | ||
| { | ||
| var countries = DataSource._olympics_2024.Where(c => c.ContinentCode == continent.Code).OrderByDescending(c => c.Medals.Total); | ||
|
|
||
| var continentItem = new OlympicGridItem | ||
| { | ||
| Item = continent with | ||
| { | ||
| Medals = new Medals() | ||
| { | ||
| Gold = countries.Sum(c => c.Medals.Gold), | ||
| Silver = countries.Sum(c => c.Medals.Silver), | ||
| Bronze = countries.Sum(c => c.Medals.Bronze), | ||
| } | ||
| }, | ||
| IsCollapsed = true | ||
| }; | ||
|
|
||
| items.Add(continentItem); | ||
|
|
||
| foreach (var country in countries) | ||
| { | ||
| var countryItem = new OlympicGridItem | ||
| { | ||
| Item = country, | ||
| Depth = 1, | ||
| IsHidden = true | ||
| }; | ||
| continentItem.Children.Add(countryItem); | ||
| items.Add(countryItem); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class OlympicGridItem : HierarchicalGridItem<Country, OlympicGridItem> | ||
| { | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
examples/Demo/Shared/Pages/DataGrid/Examples/DataGridHierarchicalOrgChart.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| @using Microsoft.FluentUI.AspNetCore.Components | ||
| @using FluentUI.Demo.Shared.SampleData | ||
|
|
||
| <p> | ||
| <FluentButton Appearance="Appearance.Accent" IconStart="@(ceoItem?.IsCollapsed == true ? new Icons.Regular.Size16.Add() : new Icons.Regular.Size16.Subtract())" | ||
| OnClick="@ToggleCEO"> | ||
| @(ceoItem?.IsCollapsed == true ? "Expand" : "Collapse") CEO | ||
| </FluentButton> | ||
| </p> | ||
|
|
||
| <FluentDataGrid Items="@items.Where(i => !i.IsHidden).AsQueryable()" ResizableColumns="true"> | ||
| <TemplateColumn Title="Name" HierarchicalToggle="true"> | ||
| @(context.Item.FirstName + " " + context.Item.LastName) | ||
| </TemplateColumn> | ||
| <PropertyColumn Title="Job Title" Property="@(i => i.Item.JobTitle)" /> | ||
| <PropertyColumn Title="Department" Property="@(i => i.Item.Department)" /> | ||
| <PropertyColumn Title="Location" Property="@(i => i.Item.Location)" /> | ||
| </FluentDataGrid> | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.