189 lines
7.1 KiB
Plaintext
189 lines
7.1 KiB
Plaintext
@typeparam TDataModel where TDataModel : IDataModel
|
|
|
|
@inject ContextMenuService ContextMenuService
|
|
|
|
<RadzenDataGrid Style="height:calc(100vh - 23rem); font-size: 20px;" TItem="TDataModel" Data="@DataList" AllowPaging PageSize="100"
|
|
AllowFiltering FilterMode="FilterMode.Advanced" CellRender="@CellRender"
|
|
SelectionMode="DataGridSelectionMode.Single" @bind-Value="@SelectedRow"
|
|
CellContextMenu="@OnCellContextMenu" RowSelect="@SelectRow">
|
|
<Columns>
|
|
|
|
@if (VisibleRowNo == true)
|
|
{
|
|
<RadzenDataGridColumn Title="No.">
|
|
<Template>
|
|
@(DataList.ToList().IndexOf(context) + 1)
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
|
|
@foreach (var col in typeof(TDataModel).GetProperties())
|
|
{
|
|
if (col.Name.ToLower().Equals("rn") || col.Name.ToLower().Equals("stepversion"))
|
|
continue;
|
|
|
|
if (col.Name.ToLower().Equals("testdate"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span class="custom-rz-value rz-color-secondary">
|
|
@Convert.ToDateTime(col.GetValue(context)).ToString("yyyy-MM-dd")
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Equals("ok"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span class="custom-rz-value" style="color: lime;">
|
|
@col.GetValue(context)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Equals("ng"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span class="custom-rz-value" style="color:red;">
|
|
@col.GetValue(context)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span class="custom-rz-value">
|
|
@col.GetValue(context)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
}
|
|
</Columns>
|
|
</RadzenDataGrid>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public IEnumerable<TDataModel> DataList { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TDataModel> OnSelectRow { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback OnClickContextMenu { get; set; }
|
|
|
|
[Parameter]
|
|
public bool VisibleRowNo { get; set; }
|
|
|
|
[Parameter]
|
|
public bool HostColumnMerge { get; set; }
|
|
|
|
private IList<TDataModel> SelectedRow;
|
|
|
|
private void CellRender(DataGridCellRenderEventArgs<TDataModel> args)
|
|
{
|
|
if (args.Column.Property == null)
|
|
return;
|
|
|
|
//testdate 컬럼일때 날짜 병합
|
|
if (args.Column.Property.ToLower().Equals("testdate"))
|
|
{
|
|
var properties = typeof(TDataModel).GetProperties().ToList();
|
|
|
|
var testDate = properties.Find(x => x.Name.ToLower() == "testdate");
|
|
var host = properties.Find(x => x.Name.ToLower() == "host");
|
|
var section = properties.Find(x => x.Name.ToLower() == "section");
|
|
|
|
if (testDate != null && host != null && section != null)
|
|
{
|
|
var rowTestDate = testDate.GetValue(args.Data);
|
|
var rowHost = host.GetValue(args.Data);
|
|
var rowSection = section.GetValue(args.Data);
|
|
|
|
var data = DataList.First(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate);
|
|
if (data != null)
|
|
{
|
|
var dataTestDate = testDate.GetValue(data);
|
|
var dataHost = host.GetValue(data);
|
|
var dataSection = section.GetValue(data);
|
|
|
|
if (rowHost == dataHost && rowSection == dataSection)
|
|
{
|
|
int rowCount = DataList.Count(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate);
|
|
|
|
args.Attributes.Add("rowspan", rowCount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//host merge 옵션
|
|
if (HostColumnMerge == true)
|
|
{
|
|
if (args.Column.Property.ToLower().Equals("host"))
|
|
{
|
|
var properties = typeof(TDataModel).GetProperties().ToList();
|
|
|
|
var testDate = properties.Find(x => x.Name.ToLower() == "testdate");
|
|
var host = properties.Find(x => x.Name.ToLower() == "host");
|
|
var section = properties.Find(x => x.Name.ToLower() == "section");
|
|
|
|
if (testDate != null && host != null && section != null)
|
|
{
|
|
var rowTestDate = testDate.GetValue(args.Data);
|
|
var rowHost = host.GetValue(args.Data);
|
|
var rowSection = section.GetValue(args.Data);
|
|
|
|
var data = DataList.First(x => host.GetValue(x).ToString() == rowHost.ToString());
|
|
if (data != null)
|
|
{
|
|
var dataTestDate = testDate.GetValue(data);
|
|
var dataHost = host.GetValue(data);
|
|
var dataSection = section.GetValue(data);
|
|
|
|
if (rowHost == dataHost && rowSection == dataSection)
|
|
{
|
|
int rowCount = DataList.Count(x => host.GetValue(x).ToString() == rowHost.ToString());
|
|
|
|
args.Attributes.Add("rowspan", rowCount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private async Task OnCellContextMenu(DataGridCellMouseEventArgs<TDataModel> args)
|
|
{
|
|
SelectedRow = new List<TDataModel>() { args.Data };
|
|
|
|
ContextMenuService.Open(args,
|
|
new List<ContextMenuItem> {
|
|
new ContextMenuItem(){ Text = "Overview", Value = 1, Icon = "home" },
|
|
new ContextMenuItem(){ Text = "Detail Overview", Value =2 , Icon = "assessment" },
|
|
new ContextMenuItem(){ Text = "Test History", Value = 3, Icon = "description" },
|
|
new ContextMenuItem(){ Text = "Test Summary", Value = 4, Icon = "assignment_turned_in" },
|
|
new ContextMenuItem(){ Text = "Detail Data", Value = 5, Icon = "list" },
|
|
new ContextMenuItem(){ Text = "Test-Error/Extended Search", Value = 6, Icon = "search" },
|
|
},
|
|
(e) =>
|
|
{
|
|
ContextMenuService.Close();
|
|
OnClickContextMenu.InvokeAsync();
|
|
}
|
|
);
|
|
|
|
await OnSelectRow.InvokeAsync(args.Data);
|
|
}
|
|
|
|
private async Task SelectRow(TDataModel data)
|
|
{
|
|
await OnSelectRow.InvokeAsync(data);
|
|
StateHasChanged();
|
|
}
|
|
}
|