-
Notifications
You must be signed in to change notification settings - Fork 461
[DataGrid] Add AutoFit feature to size columns automatically as good as possible #2496
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
ef42d45
Add AutoFit feature to FluentDataGrid component
3aef85c
Merge branch 'dev' into 2495-AutoFit
ksbecker dc1ccec
Merge branch 'dev' into 2495-AutoFit
dvoituron 00d773e
Provide better comment for the AutoFit feature and fix merge conflictβ¦
705bd77
Merge branch 'dev' into 2495-AutoFit
dvoituron 35ef9ae
Add AutoFit parameter to FluentDataGrid component
a9f0068
Merge branch 'dev' into 2495-AutoFit
vnbaaij 3900e12
Place `Parameter` attribute on separate line for `AutoFit`. Also fixeβ¦
ccd9594
Merge branch 'dev' into 2495-AutoFit
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
57 changes: 57 additions & 0 deletions
57
examples/Demo/Shared/Pages/DataGrid/Examples/DataGridAutoFit.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,57 @@ | ||
| ο»Ώ@using System.ComponentModel.DataAnnotations | ||
|
|
||
| <FluentGrid Spacing="4"> | ||
| <FluentGridItem xs="12"> | ||
| <h4>With auto-fit</h4> | ||
| <FluentDataGrid Items="@people" AutoFit="true"> | ||
| <PropertyColumn Property="@(p => p.PersonId)" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.Name)" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.Bio)" /> | ||
| </FluentDataGrid> | ||
| </FluentGridItem> | ||
| <FluentGridItem xs="12"> | ||
| <h4>Without auto-fit</h4> | ||
| <FluentDataGrid Items="@people"> | ||
| <PropertyColumn Property="@(p => p.PersonId)" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.Name)" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" /> | ||
| <PropertyColumn Property="@(p => p.Bio)" /> | ||
| </FluentDataGrid> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
| public class Person | ||
| { | ||
| public Person(int personId, string name, DateOnly birthDate, string bio) | ||
| { | ||
| PersonId = personId; | ||
| Name = name; | ||
| BirthDate = birthDate; | ||
| Bio = bio; | ||
| } | ||
|
|
||
| [Display(Name = "Identity")] | ||
| public int PersonId { get; set; } | ||
|
|
||
| [Display(Name = "Name")] | ||
| public string Name { get; set; } | ||
|
|
||
| [Display(Name = "Birth date")] | ||
| public DateOnly BirthDate { get; set; } | ||
|
|
||
| [Display(Name = "Biography")] | ||
| public string Bio { get; set; } | ||
| } | ||
|
|
||
| IQueryable<Person> people = new[] | ||
| { | ||
| new Person(10895, "Jean Martin", new DateOnly(1825, 11, 29), "Born on November 29, 1825, in Paris, France, is renowned as the founder of modern neurology."), | ||
| new Person(10944, "AntΓ³nio Langa", new DateOnly(1972, 5, 15), "Born on May 15, 1972, in Columbia, South Carolina, is a distinguished former professional basketball player."), | ||
| new Person(11203, "Julie Smith", new DateOnly(1944, 11, 25), "Born on November 25, 1944, in Annapolis, Maryland, is an acclaimed American mystery writer celebrated for her rich storytelling."), | ||
| new Person(11205, "Nur Sari", new DateOnly(1922, 4, 27), "Nur Sari is a fictional character known for her extraordinary contributions to the field of renewable energy."), | ||
| new Person(11898, "Jose Hernandez", new DateOnly(1962, 8, 7), "Born on August 7, 1962, in French Camp, California, is a Mexican-American engineer."), | ||
| new Person(12130, "Kenji Sato", new DateOnly(2004, 1, 9), ""), | ||
| }.AsQueryable(); | ||
| } |
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
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
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
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.