Browse Source

Fix empty ExtraProperties cells in AbpExtensibleDataGrid

The implicit DisplayTemplate context caused the Razor source generator
to compile 'context.Item as IHasExtraProperties' into
'context as IHasExtraProperties' (dropping the .Item access). Since
CellDisplayContext<TItem> itself does not implement IHasExtraProperties,
the cast was always null and the cell rendered empty.

Renaming the context with Context="rowContext" produces the correct
'rowContext.Item as IHasExtraProperties' codegen and the cell now
shows the property value.
pull/25480/head
maliming 4 months ago
parent
commit
ad6de43563
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 6
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

6
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

@ -120,9 +120,9 @@
else
{
<DataGridColumn TItem="TItem" Field="@nameof(IHasExtraProperties.ExtraProperties)" SortField="@column.PropertyName" Width="@BlazoriseFluentSizingParse.Parse(column.Width, SizingType.Width)" Caption="@column.Title" Displayable="column.Visible" Sortable="@column.Sortable">
<DisplayTemplate>
<DisplayTemplate Context="rowContext">
@{
var entity = context.Item as IHasExtraProperties;
var entity = rowContext.Item as IHasExtraProperties;
var propertyName = ExtensionPropertiesRegex.Match(column.Data).Groups[1].Value;
var propertyValue = entity?.GetProperty(propertyName);
if (propertyValue != null && propertyValue.GetType() == typeof(bool))
@ -140,7 +140,7 @@
{
if (column.ValueConverter != null)
{
@((MarkupString)GetConvertedFieldValue(context.Item, column))
@((MarkupString)GetConvertedFieldValue(rowContext.Item, column))
}
else
{

Loading…
Cancel
Save