Changing sfgrid datasource does not work in Blazor | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

Changing sfgrid datasource does not work in Blazor

Date- Jun 11,2022

3873

Blazor Syncfusion


SFGrid in Blazor

SFGrid is a grid component provided by synfcusion that we use in blazor to create grid's that have some amazing features like incremental search, agreggate sum, pagination and many more column formatting.

The issue occurs when you pass any datasource to SFGrid and than try to pass different datasource to that. You will notice it doesn't refresh the schema of grid as per the passed datasource. In that case we have to do this

@if (RenderGridData) 
{ 
    <SfGrid 
    @ref="gridObj" 
    Height="400px" 
    Width="100%" 
    TValue="ExpandoObject" 
    DataSource=@data> 
    </SfGrid> 
} 
 
    public bool RenderGridData= true; 
    public async Task OnGenerateNewData() 
    { 
        RenderGridData= false; 
        await Task.Yield(); 
        this.data = RandomDataSource(); 
        RenderGridData= true; /*Set True after changing the datasource*/
}

As you can see , we have to keep the component inside a bool variable and than we have to set the value to false before changing the datasource and than put it back to true after the datasource is changed. Now , run the application and you will see your grid component will refresh as per the passed datasource.

So, this is how you can solve the issue Changing sfgrid datasource does not work in Blazor.

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1210
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts