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; }
}
}
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