206 lines
7.4 KiB
Plaintext
206 lines
7.4 KiB
Plaintext
@using WebClient.Library.Model
|
|
@typeparam TDataModel
|
|
|
|
<RadzenDataGrid class="rz-shadow-1" TItem="TDataModel" Data="@DataList" GridLines="DataGridGridLines.Both"
|
|
AllowFiltering FilterMode="FilterMode.Advanced" CellRender="@CellRender" AllowColumnResize AllowVirtualization
|
|
SelectionMode="DataGridSelectionMode.Single" @bind-Value="@SelectedRow" Density="@Density.Default"
|
|
RowSelect="@SelectRow" RowDoubleClick="@OnRowDoublClick">
|
|
<Columns>
|
|
@if (VisibleRowNo == true)
|
|
{
|
|
<RadzenDataGridColumn Title="No.">
|
|
<Template>
|
|
<span class="custom-rz-value">
|
|
@(DataList.ToList().IndexOf(context) + 1)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
|
|
@foreach (var col in typeof(TDataModel).GetProperties())
|
|
{
|
|
//disable filter
|
|
if (GlobalGridDisableFilter?.Filter?.Exists(x => x.ToLower() == col.Name.ToLower()) == true)
|
|
continue;
|
|
|
|
if (GridDisableFilter?.Filter?.Exists(x=>x.ToLower() == col.Name.ToLower()) == true)
|
|
continue;
|
|
|
|
if (col.Name.ToLower().Equals("testdate"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name" Width="10rem">
|
|
<Template>
|
|
<span class="rz-color-secondary">
|
|
@Convert.ToDateTime(col.GetValue(context)).ToString("yyyy-MM-dd")
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Equals("testdatetime"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name" Width="20rem">
|
|
<Template>
|
|
<span>
|
|
@Convert.ToDateTime(col.GetValue(context)).ToString("yyyy-MM-dd HH:mm:ss")
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Equals("ok"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span 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 style="color:red;">
|
|
@col.GetValue(context)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Contains("cntid") || col.Name.ToLower().Contains("reqid"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name" Width="20rem">
|
|
<Template>
|
|
<span>
|
|
@col.GetValue(context)
|
|
</span>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else if (col.Name.ToLower().Contains("activate"))
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name" Width="20rem">
|
|
<Template>
|
|
<RadzenCheckBox TValue="bool" Value="@Convert.ToBoolean(col.GetValue(context))">
|
|
</RadzenCheckBox>
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
}
|
|
else
|
|
{
|
|
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
|
<Template>
|
|
<span>
|
|
@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<TDataModel> OnDoubleClickRow{ get; set; }
|
|
|
|
[Parameter]
|
|
public bool VisibleRowNo { get; set; }
|
|
|
|
[Parameter]
|
|
public bool HostColumnMerge { get; set; }
|
|
|
|
[Parameter]
|
|
public EnumTabs EnumTab { get; set; }
|
|
private GridDisableFilter GlobalGridDisableFilter = new();
|
|
private GridDisableFilter GridDisableFilter = new();
|
|
|
|
private IList<TDataModel> SelectedRow;
|
|
|
|
private string SummaryTestResult = string.Empty;
|
|
private string SummaryTestTime = string.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
GlobalGridDisableFilter = configService?.GetConfig()?.GridDisableFilter.Where(x => x.EnumTabs == 1)?.FirstOrDefault();
|
|
GridDisableFilter = configService?.GetConfig()?.GridDisableFilter.Where(x => x.EnumTabs == (int)EnumTab)?.FirstOrDefault();
|
|
}
|
|
|
|
private void CellRender(DataGridCellRenderEventArgs<TDataModel> args)
|
|
{
|
|
// if (args.Column.Property == null)
|
|
// return;
|
|
|
|
// var cellData = args.Data as Overview;
|
|
// if (cellData is null)
|
|
// return;
|
|
|
|
// if ((args.Column.Property.ToLower().Equals("testdate") || args.Column.Property.ToLower().Equals("host")) == false)
|
|
// return;
|
|
|
|
// int index = DataList.ToList().FindIndex(x => x.Equals(args.Data));
|
|
|
|
// //testdate 컬럼일때 날짜 병합
|
|
// if (args.Column.Property.ToLower().Equals("testdate"))
|
|
// {
|
|
// int rowCount = 0;
|
|
// var take = DataList.Skip(index).Cast<Overview>();
|
|
// foreach (var r in take)
|
|
// {
|
|
// if (r.TestDate.Value.Date == cellData.TestDate.Value.Date)
|
|
// {
|
|
// if (r.ModelName == cellData.ModelName)
|
|
// {
|
|
// rowCount += 1;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// break;
|
|
// }
|
|
// }
|
|
// args.Attributes.Clear();
|
|
// if (rowCount > 0)
|
|
// args.Attributes.Add("rowspan", rowCount);
|
|
// }
|
|
|
|
// if (args.Column.Property.ToLower().Equals("host"))
|
|
// {
|
|
// if (HostColumnMerge == false)
|
|
// return;
|
|
|
|
// int rowCount = 0;
|
|
// var take = DataList.Skip(index).Cast<Overview>();
|
|
// foreach (var r in take)
|
|
// {
|
|
// if (r.Host == cellData.Host)
|
|
// {
|
|
// rowCount += 1;
|
|
// }
|
|
// else
|
|
// {
|
|
// break;
|
|
// }
|
|
// }
|
|
// args.Attributes.Clear();
|
|
// if (rowCount > 0)
|
|
// args.Attributes.Add("rowspan", rowCount);
|
|
// }
|
|
}
|
|
|
|
private async Task SelectRow(TDataModel data)
|
|
{
|
|
await OnSelectRow.InvokeAsync(data);
|
|
}
|
|
|
|
private async Task OnRowDoublClick(DataGridRowMouseEventArgs<TDataModel> args)
|
|
{
|
|
await OnDoubleClickRow.InvokeAsync(args.Data);
|
|
}
|
|
}
|