Datagrid doesnt refresh for null datasource

Hello,

I am using data grid component on my project. 

When i set datasource to null, i am expecting to see " No records to display" text on the grid but grid not refreshing and showing old records or nothing. 

To overcome this situation, i check my datasouer whether it is null or not, if it is null, i create new list.

I think it is better to check null state in the component.

Is there any property of grid to solve this stuation?

You can find the sample code below.

Regards.

----------------------------------------------------------------------------------------------------------------------------------------------

@page "/"


@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.Buttons


<SfButton OnClick="createFilledList" Content="Create filled list" />

<SfButton OnClick="setDataSourceNull" Content="Set DataSource Null" />

<SfButton OnClick="createEmptyList" Content="Create empty list" />


<div class="container">

    <SfGrid DataSource="@dataSource">

        <GridColumns>

            <GridColumn Field=@nameof(Staff.Id) HeaderText="Id"/>

            <GridColumn Field=@nameof(Staff.Name) HeaderText="Name"/>

        </GridColumns>

    </SfGrid>

</div>


@code {

    List<Staff> dataSource;


    protected override void OnInitialized()

    {

        createFilledList();

    }

    protected void setDataSourceNull()

    {

        dataSource = null;

    }

    protected void createEmptyList()

    {

        dataSource = new List<Staff>();

    }


    protected void createFilledList()

    {

        dataSource = new List<Staff> {

            new Staff { Id = 1, Name = "fhr 1" },

            new Staff { Id = 2, Name = "fhr 2" },

            new Staff { Id = 3, Name = "fhr 3" },

        };

    }


    public class Staff

    {

        public int Id { get; set; }

        public string Name{ get; set; }

    }

}


Attachment: SyncfusionTest_fd6dd8b4.rar

4 Replies

JP Jeevakanth Palaniappan Syncfusion Team November 15, 2021 02:40 PM UTC

Hi Fahri, 

Greetings from Syncfusion support. 

We are currently validating the reported problem from our end and so we will update the further details in two business days. Until then we appreciate your patience. 

Regards, 
Jeevakanth SP. 



RN Rahul Narayanasamy Syncfusion Team November 17, 2021 02:07 PM UTC

Hi Fahri,  

Thanks for your patience.  

We have validated your query and we have confirmed it as a bug and logged the defect report DataGrid does not refresh when setting Grid DataSource as null” for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and including the defect fix in our weekly release which is expected to be rolled out by the mid of December, 2021.   
        
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  
 
  
Regards,  
Rahul 



FK Fahri Korkut November 18, 2021 09:28 AM UTC

Hi Rahul,


Thank you for your response. I am using many of Syncfusion Blazor components for a special project and very happy with them. It is very nice to see quick responses and actions. Thank you again.

Regards,

Fahri



RN Rahul Narayanasamy Syncfusion Team November 19, 2021 03:41 AM UTC

Hi Fahri, 

Thanks for the update. 

We will let you know once the fix is included in our upcoming mentioned release. Till then we appreciate your patience. 

Regards, 
Rahul 


Loader.
Up arrow icon