We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Dynamic data source binding on grid

Hi, is ObservableCollection the only way to dynamically bind a datasource? I mean it seems like a step backwards from the way it used to work.

1 Reply

VN Vignesh Natarajan Syncfusion Team January 30, 2020 05:18 AM UTC

Hi Raul,  
 
Thanks for contacting Syncfusion support.  
 
Query: “is ObservableCollection the only way to dynamically bind a datasource? I mean it seems like a step backwards from the way it used to work 
 
From your query, we suspect that you are facing issue while changing the datasource dynamically / externally in Grid. While using ObservableCollection changes done externally like Add, Delete, Update item will be reflected automatically in Grid without any external action.  
 
But if you are binding the datasource in form of IEnumerable collection, after the changing the datasource. You need to call Refresh() method of Grid to reflect the changes done externally. Because tracking items of IEnumerable for changes done externally is avoided for performance considerations. 
 
Refer the below code example.  
 
<EjsButton OnClick="Clik">Save</EjsButton> 
<EjsGrid @ref="GridInstance" AllowPaging="true" DataSource="@Orders" Toolbar="@(new List<string>() { "Cancel", "Update" })"> 
. . . . . . . . . 
</EjsGrid> 
 
@code{ 
    public static EjsGrid<Order> GridInstance { get; set; } 
    public void Clik() 
    {//call refresh method after changing the datasource externally 
        GridInstance.Refresh(); 
    } 
 
If above solution does not resolve your query, kindly get back to us with more details about your issue or requirement.  
 
Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon