Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.26k stars 528 forks source link

Datagrid: Loads 2 times on first render #1678

Closed David-Moreira closed 3 years ago

David-Moreira commented 3 years ago

Hello @stsrki hope you've been well... :) Describe the bug I'm not sure if this is something to do with Blazor triggering a re-render or Datagrid or if it's just me missing something. But I noticed that on the first load, datagrid actually ends up loading 2 times, meaning that it calls ReadData twice.

To Reproduce Steps to reproduce the behavior: Tested with a new project, with Blazor Server set to render-mode="Server" Just init datagrid with ReadData set. It will call it two times. Here's the demo source in screenshots... :P

image image

Doesn't seem to make sense taking into account the source code, do you know what it could be?:

       protected override Task OnAfterRenderAsync( bool firstRender )
        {
            if ( firstRender )
            {
                if ( ManualReadMode )
                    return HandleReadData();

                // after all the columns have being "hooked" we need to resfresh the grid
                InvokeAsync( () => StateHasChanged() );
            }

            return base.OnAfterRenderAsync( firstRender );
        }
paulosdfigueiredo commented 3 years ago

Hi,

It's a known issue, duplicate of #1609.

There's an open PR #1662 to fix it.

David-Moreira commented 3 years ago

Oh I'm blind, haven't been paying attention to the latest issues!! Great thanks @paulosdfigueiredo! Closing issue. 👍