forked from MudBlazor/MudBlazor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MudBlazor#4921: Guid is not working with DataGrid Bindings
- Loading branch information
Showing
6 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridFilterDictionaryGuid.razor
This file contains 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,46 @@ | ||
@namespace MudBlazor.UnitTests.TestComponents | ||
|
||
<MudGrid> | ||
<MudItem xs="12"> | ||
<MudDataGrid T="IDictionary<string, object>" | ||
@ref="MudGridRef" | ||
Items="@forecasts" | ||
Filterable="true"> | ||
<Columns> | ||
<Column T="IDictionary<string, object>" FieldType="@typeof(Guid)" Field="Id" Title="Id" Sortable="true" /> | ||
<Column T="IDictionary<string, object>" FieldType="@typeof(DateTime)" Field="Date" Title="Date" Sortable="true" /> | ||
<Column T="IDictionary<string, object>" FieldType="@typeof(int)" Field="TemperatureC" Title="Temp. (C)" Sortable="true" /> | ||
<Column T="IDictionary<string, object>" FieldType="@typeof(string)" Field="Summary" Title="Summary" Sortable="true" /> | ||
</Columns> | ||
</MudDataGrid> | ||
</MudItem> | ||
</MudGrid> | ||
|
||
@code { | ||
public MudDataGrid<IDictionary<string, object>> MudGridRef { get; private set; } | ||
private IEnumerable<IDictionary<string, object>> forecasts = new List<IDictionary<string, object>>(); | ||
|
||
public string Guid1 => "98ee67d6-0302-40f4-935a-0014e712a9e1"; | ||
public string Guid2 => "C3D88136-44AF-4955-B422-5EE13463FDCE"; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
forecasts = new List<IDictionary<string, object>>() | ||
{ | ||
new Dictionary<string, object> | ||
{ | ||
{ "Id", Guid.Parse(Guid1) }, | ||
{ "Date", DateTime.UtcNow }, | ||
{ "TemperatureC", 14 }, | ||
{ "Summary", "Bracing" }, | ||
}, | ||
new Dictionary<string, object>() | ||
{ | ||
{ "Id", Guid.Parse(Guid2) }, | ||
{ "Date", DateTime.UtcNow }, | ||
{ "TemperatureC", 14 }, | ||
{ "Summary", "Bracing" }, | ||
}, | ||
}; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridFilterGuid.razor
This file contains 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,79 @@ | ||
@namespace MudBlazor.UnitTests.TestComponents | ||
@typeparam TItem | ||
|
||
<MudGrid> | ||
<MudItem xs="12"> | ||
<MudDataGrid T="WeatherForecast" | ||
@ref="MudGridRef" | ||
Elevation="25" | ||
Items="@forecasts" | ||
Hover="true" | ||
Outlined="false" | ||
Filterable="true" | ||
Loading="@_loading" | ||
Height="500px" | ||
Bordered="true" | ||
FixedHeader="true"> | ||
<Columns> | ||
<Column T="WeatherForecast" Field="@nameof(WeatherForecast.Id)" Title="Id" Sortable="true" /> | ||
<Column T="WeatherForecast" Field="@nameof(WeatherForecast.Date)" Title="Date" Sortable="true" /> | ||
<Column T="WeatherForecast" Field="@nameof(WeatherForecast.TemperatureC)" Title="Temp. (C)" Sortable="true" /> | ||
<Column T="WeatherForecast" Field="@nameof(WeatherForecast.TemperatureF)" Title="Temp. (F)" Sortable="true" /> | ||
<Column T="WeatherForecast" Field="@nameof(WeatherForecast.Summary)" Title="Summary" Sortable="true" /> | ||
</Columns> | ||
<PagerContent> | ||
<MudDataGridPager T="WeatherForecast" /> | ||
</PagerContent> | ||
</MudDataGrid> | ||
</MudItem> | ||
</MudGrid> | ||
|
||
@code { | ||
public MudDataGrid<WeatherForecast> MudGridRef { get; private set; } | ||
private bool _loading; | ||
private IEnumerable<WeatherForecast> forecasts = new List<WeatherForecast>(); | ||
|
||
public string Guid1 => "98ee67d6-0302-40f4-935a-0014e712a9e1"; | ||
public string Guid2 => "C3D88136-44AF-4955-B422-5EE13463FDCE"; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_loading = true; | ||
forecasts = new List<WeatherForecast>() | ||
{ | ||
new WeatherForecast() | ||
{ | ||
Id = ParseId(Guid1), | ||
Date = DateTime.UtcNow, | ||
TemperatureC = 14, | ||
Summary = "Bracing" | ||
}, | ||
new WeatherForecast() | ||
{ | ||
Id = ParseId(Guid2), | ||
Date = DateTime.UtcNow, | ||
TemperatureC = 64, | ||
Summary = "Bracing" | ||
}, | ||
}; | ||
_loading = false; | ||
} | ||
|
||
private TItem ParseId(string id) | ||
{ | ||
return Guid.Parse(id) as dynamic; | ||
} | ||
|
||
public class WeatherForecast | ||
{ | ||
public TItem Id { get; set; } | ||
|
||
public DateTime Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public string Summary { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.