Created
March 20, 2024 14:21
-
-
Save mxmissile/491e8671df7ef6b402f035765e1318a0 to your computer and use it in GitHub Desktop.
vertical table?
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
@if (_data != null) | |
{ | |
var dates = _data.Select(x => x.Date).Distinct(); | |
<table> | |
<tr> | |
@foreach (var date in dates) | |
{ | |
<th>@date.ToShortDateString()</th> | |
} | |
</tr> | |
@foreach (var date in dates) | |
{ | |
var items = _data.Where(x => x.Date == date); | |
// ? | |
} | |
</table> | |
} | |
@code { | |
private Datum[]? _data; | |
protected override void OnInitialized() | |
{ | |
var list = new List<Datum>(); | |
for (var i = 0; i < 10; i++) | |
{ | |
list.Add(new Datum { Date = DateTime.Today, Number = i }); | |
} | |
for (var i = 0; i < 10; i++) | |
{ | |
list.Add(new Datum { Date = DateTime.Today.AddDays(1), Number = i }); | |
} | |
for (var i = 0; i < 10; i++) | |
{ | |
list.Add(new Datum { Date = DateTime.Today.AddDays(2), Number = i }); | |
} | |
_data = list.ToArray(); | |
} | |
public class Datum | |
{ | |
public DateTime Date { get; set; } | |
public int Number { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment