I am having an issue with the DataGrid and the intrinsic search fields. I am using AllowVirtualization="true" and using Type="typeof(string)". The any search causes this error:
blazor.server.js:19 [2021-07-29T22:09:03.252Z] Error: No property or field 'Logs' exists in type 'Logs' (at index 2)
This is the basic configuration:
@inject logContext logdb;
<RadzenCard Style=@string.Concat("height: 600px; width: 99%; background-color:linen; padding: 5px;", context.isLoadingStyle)>
<RadzenDataGrid Data="@evLog" IsLoading="@isLoading" Count="@count" PageSize="50" TItem="Logs" @ref="evGrid"
RowRender="@RowRender" CellRender="@CellRender" AllowVirtualization="true" AllowFiltering="true"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" LogicalFilterOperator="LogicalFilterOperator.Or"
AllowPaging="false" AllowSorting="true" Style="line-height: 14px; width:100%; height: 585px; margin-right:5px;" Type="typeof(Date)">
<Columns>
@*Main Grid View*@
<RadzenDataGridColumn Width="75px" TItem="Logs" Property="Logs.Timestamp" Title="Time Stamp" TextAlign="TextAlign.Left" />
<RadzenDataGridColumn Width="60px" TItem="string" Visible="@ShowIPColumn" Property="@IPAddress" Title="IP Adress" TextAlign="TextAlign.Left" Type="typeof(string)" />
<RadzenDataGridColumn Width="100px" TItem="Logs" Property="Logs.SourceContext" Title="Source Context" TextAlign="TextAlign.Center" Type="typeof(string)" />
<RadzenDataGridColumn Width="100px" TItem="Logs" Property="Logs.Level" Title="Level" TextAlign="TextAlign.Center" Type="typeof(string)" />
<RadzenDataGridColumn Width="600px" TItem="Logs" Property="Logs.Message" Title="Message" TextAlign="TextAlign.Left" Type="typeof(string)">
<Template Context="logs">
<RadzenImage Path=@GetIconPath(logs) Style="width:12px; height:12px" />
@((MarkupString)GetMessageSpan(logs))
</Template>
</RadzenDataGridColumn>
</Columns>
@*Style="line-height: 12px; width: 99%;"> <--- This can go back in the next Radzen release, current ver: 2.10.5 Now fixed in 2.10.13 https://forum.radzen.com/t/datagrid-style-not-working-as-expected/4009 *@
<Template Context="logItem">
@*Expanded grid*@
<RadzenDataGrid Data="@GetLogItem(logItem)" TItem="Logs" CellRender="@ItemCellRender" AllowPaging="false" AllowSorting="false" AllowFiltering="false">
<Columns>
<RadzenDataGridColumn Width="600px" TItem="Logs" Property="log.Message" Type="typeof(string)">
<Template Context="logMessage">
@((MarkupString)GetExpandText(logMessage, true))
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</Template>
</RadzenDataGrid>
</RadzenCard>
@code {
IEnumerable<Logs> evLog;
RadzenDataGrid<Logs> evGrid;
// Logs is an entity class consisting of the grid fields
protected override void OnInitialized()
{
evLog = logdb.Logs.OrderByDescending(Logs => Logs.Timestamp);
}
private string GetMessageSpan(Logs log)
{
context.IsLoading = true;
try
{
bool expand = false;
string retMsg = string.Empty;
string color = "black";
string fontSize = "12px";
string retStr = string.Empty;
// some formatting code
retStr += $"<span style='color:{color}; font-size:{fontSize}; white-space:pre-wrap'>{retMsg}</span>";
context.IsLoading = false;
return retStr;
}
private string GetExpandText(Logs log, bool expand)
{
context.IsLoading = true;
string retMsg = string.Empty;
string color = "black";
string fontSize = "12px";
string retStr = string.Empty;
// some formatting code
retStr += $"<span style='color:{color}; font-size:{fontSize}; white-space:pre-wrap'>{retMsg}</span>";
context.IsLoading = false;
return retStr;
}
}
Class Logs:
Public Class Logs
Public Overridable Property id As Integer
Public Overridable Property Timestamp As DateTime
<StringLength(50)> Public Overridable Property Level As String
<StringLength(50)> Public Overridable Property Template As String
<StringLength(4096)> Public Overridable Property Message As String
<StringLength(4096)> Public Overridable Property Exception As String
<StringLength(4096)> Public Overridable Property Properties As String
<StringLength(50)> Public Overridable Property SourceContext As String
<StringLength(50)> Public Overridable Property groupExpanded As String
<StringLength(50)> Public Overridable Property groupCollapsed As String
<StringLength(50)> Public Overridable Property ActionId As String
<StringLength(50)> Public Overridable Property Link As String
<StringLength(50)> Public Overridable Property Node As String
<StringLength(50)> Public Overridable Property FRM As String
<StringLength(50)> Public Overridable Property UserName As String
<DatabaseGenerated(DatabaseGeneratedOption.Computed)>
Public Overridable Property _ts As DateTime
End Class
Logs is an entity framework class of the grids fields.
Thank you for any help with this. I do have a subscription.
Regards,
Orlando Davis