[성현모] Grid 성능 개선
This commit is contained in:
@ -2,9 +2,9 @@
|
||||
|
||||
@inject ContextMenuService ContextMenuService
|
||||
|
||||
<RadzenDataGrid class="rz-shadow-1" TItem="TDataModel" Data="@DataList" AllowPaging="@AllowPaging" PageSize="@PageSize"
|
||||
AllowFiltering FilterMode="FilterMode.Advanced" CellRender="@CellRender" AllowColumnResize
|
||||
SelectionMode="DataGridSelectionMode.Single" @bind-Value="@SelectedRow"
|
||||
<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)
|
||||
@ -20,8 +20,8 @@
|
||||
|
||||
@foreach (var col in typeof(TDataModel).GetProperties())
|
||||
{
|
||||
if(DisableColums?.Contains(col.Name.ToLower()) == true)
|
||||
continue;
|
||||
@* if(DisableColums?.Contains(col.Name.ToLower()) == true)
|
||||
continue; *@
|
||||
|
||||
if (col.Name.ToLower().Equals("testdate"))
|
||||
{
|
||||
@ -33,6 +33,16 @@
|
||||
</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">
|
||||
@ -52,17 +62,7 @@
|
||||
</span>
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
else if (col.Name.ToLower().Equals("testdatetime"))
|
||||
{
|
||||
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name" Width="20rem">
|
||||
<Template>
|
||||
<span>
|
||||
@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">
|
||||
@ -106,25 +106,20 @@
|
||||
[Parameter]
|
||||
public bool HostColumnMerge { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool AllowPaging { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public int PageSize { get; set; } = 30;
|
||||
|
||||
[Parameter]
|
||||
public List<string> DisableColums { get; set; }
|
||||
|
||||
private IList<TDataModel> SelectedRow;
|
||||
|
||||
private string SummaryTestResult = string.Empty;
|
||||
private string SummaryTestTime = string.Empty;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
@ -134,12 +129,12 @@
|
||||
if (args.Column.Property.ToLower().Equals("testdate"))
|
||||
{
|
||||
int rowCount = 0;
|
||||
var take = DataList.Skip(index).Take(((index / PageSize) + 1) * PageSize - index);
|
||||
var take = DataList.Skip(index).Cast<Overview>();
|
||||
foreach (var r in take)
|
||||
{
|
||||
if (r.TestDate.Value.Date == args.Data.TestDate.Value.Date)
|
||||
if (r.TestDate.Value.Date == cellData.TestDate.Value.Date)
|
||||
{
|
||||
if (r.ModelName == args.Data.ModelName)
|
||||
if (r.ModelName == cellData.ModelName)
|
||||
{
|
||||
rowCount += 1;
|
||||
}
|
||||
@ -160,10 +155,10 @@
|
||||
return;
|
||||
|
||||
int rowCount = 0;
|
||||
var take = DataList.Skip(index).Take(((index / PageSize) + 1) * PageSize - index);
|
||||
var take = DataList.Skip(index).Cast<Overview>();
|
||||
foreach (var r in take)
|
||||
{
|
||||
if (r.Host == args.Data.Host)
|
||||
if (r.Host == cellData.Host)
|
||||
{
|
||||
rowCount += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user