Open Closed

Blazorize DataGrid Exception thrown on every Grid that binds to an Enum value #6724


User avatar
0
okains created
  • ABP Framework version: v8.0.3
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): NO
  • Exception message and full stack trace:

System.AggregateException: One or more errors occurred. (Cannot detect the member of SITO.Countries.CountryDto (Parameter 'WorldRegion?')) ---> System.ArgumentException: Cannot detect the member of SITO.Countries.CountryDto (Parameter 'WorldRegion?') at Blazorise.DataGrid.Utils.FunctionCompiler.GetSafePropertyOrField(Expression item, String propertyOrFieldName) at Blazorise.DataGrid.Utils.FunctionCompiler.CreateValueGetter[TItem](String fieldName) at Blazorise.DataGrid.DataGridColumn1.<.ctor>b__10_2() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at Blazorise.DataGrid.DataGridColumn1.GetValue(TItem item) at Blazorise.DataGrid._BaseDataGridRow1.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync() --- End of inner exception stack trace ---

  • Steps to reproduce the issue:

This is happening with all grids that bind to an enum. The data loads and renders correctly, then I get a client error along with the above Stack Trace:

  if (!t)
            throw new Error(`No interop methods are registered for renderer ${e}`);
        return t
    }

Also for more information here is the CountryDto:

namespace SITO.Countries { public abstract class CountryDtoBase : FullAuditedEntityDto<Guid> { public string? Name { get; set; } public string? Currency { get; set; } public string? ISOCode { get; set; } public int PhoneCountryCode { get; set; } public WorldRegion? WorldRegion { get; set; } public bool IsPublished { get; set; }

}

}

I have already generated code with ABPSuite for this entire data model, with maybe 10 affected entities. Need to find a fix for this ASAP so we can move forward.

Thanks,

Karim


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a simple project to reproduce? liming.ma@volosoft.com
    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

  • User Avatar
    0
    okains created

    This is still throwing the same error, screenshot below. I didn't change any code, just generated straight from ABP Suite, exactly as discussed. Added a Country as shown, with Asia selected, and getting the same error message.

    I have tested this in Chrome, Firefox, Edge, Brave browsers, all the same error.

    The DataGrid field is generated as nullable right from ABP Suite:

              &lt;DataGridColumn TItem=&quot;CountryDto&quot;
                      Field=&quot;PhoneCountryCode&quot;
                      Caption=&quot;@L[&quot;PhoneCountryCode&quot;]&quot;&gt;
              &lt;/DataGridColumn&gt;
    
              &lt;DataGridColumn TItem=&quot;CountryDto&quot;
                      Field=&quot;WorldRegion?&quot;
                      Caption=&quot;@L[&quot;WorldRegion&quot;]&quot;&gt;
                    &lt;DisplayTemplate&gt;
                        @L[$"Enum:WorldRegion.{context.WorldRegion?.ToString("d")}"]
                    &lt;/DisplayTemplate&gt;
              &lt;/DataGridColumn&gt;
              
    

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please change the Field="WorldRegion?" to Field="WorldRegion"

    We will update the suite code.

  • User Avatar
    0
    okains created

    OK so yes Non Nullable Enums work with the Blazorise Grid. I tried changing the Enum to Non Nullable but when I regenerated with ABPSuite it gave me some bad code, maybe you can take a look at this also ( screenshot below ). So updating to Non Nullable isn't an option for me.

    Removing the Nullable Enum field from the DataGrid is the workaround for now. Please let me know when you think this issue can / will be fixed so that I can plan accordingly.

    Also since this is a bug can you please credit me back this support ticket?

    Thanks,

    Karim

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Changing the Field="WorldRegion?" to Field="WorldRegion", should be a quick workaround in your case. You don't need to set it as non-nullable in the ABP Suite UI and re-generate the entity again. We will fix this bug in the upcoming version, thanks for reporting.

    Also since this is a bug can you please credit me back this support ticket?

    I have refunded your ticket. Best regards.

  • User Avatar
    0
    okains created

    OK perfect, thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35