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

Refresh grid datasource (Blazor)

Hi,

can you give me some advice on how to refresh the datasource of the grid in blazor?
I have the following code:

<EjsGrid ID="stample-grid" DataSrouce="@SelectedProduct?.Categories" AllowPaging="true">
    <GridSelectionSettings PersistSelection="true"></GridSelectionSettings>
    <GridColumns>
        <GridColumn Field="@nameof(Category.Name)" HeaderText="Name" />
        <GridColumn Field="@nameof(Category.Description)" HeaderText="Description" />
    </GridColumns>
</EjsGrid>

The property "Categories" contains product specific categories but of course only if a product is selected (see the ?-operator). But unfortenately the datasource never gets updated. What am I doing wrong here?

Best regards
Felix

4 Replies

HJ Hariharan J V Syncfusion Team May 23, 2019 03:27 PM UTC

Hi Felix, 
  
Thanks for contacting Syncfusion support. 
  
We have checked your query and we have found that you have mentioned the DataSource property with incorrectly. Also, We have prepared a simple sample in which DataSource can be binded to grid without any issue. Please refer the following code snippet and sample link for your reference. 
  
[Index.razor] 
<EjsGrid id="Grid" DataSource="@gridData" AllowPaging="true"> 
    <GridPageSettings PageSize="5"></GridPageSettings> 
    <GridSelectionSettings PersistSelection="true"></GridSelectionSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        .  .  .  . 
    </GridColumns> 
</EjsGrid> 
  
  
@functions { 
    public object gridData { get; set; } 
    protected override void OnInit() 
    { 
        gridData = OrdersDetails.GetAllRecords(); 
    } 
} 
  
  
Please get back to us for further assistance. 
  
Regards, 
Hariharan 



FE Felix May 24, 2019 06:49 AM UTC

Oh ... that was just a typo. But it's fine in my project. I can confirm that your sample project works flawlessly. I will now investigate why my project does not and I will contact you if I have further questions. Thank you for your help!


FE Felix May 24, 2019 09:08 AM UTC

Okay, everything works now. I had the <EjsGrid> in a separate component. As a result, the events did not work properly.

I have another question regarding licensing. Is it correct that all Syncfusion components can be used for free and without restrictions by private developers through a community license? And how do I know that I have the appropriate license key?

Best regards
Felix


TS Thavasianand Sankaranarayanan Syncfusion Team May 27, 2019 01:05 PM UTC

Hi Felix, 
 
Thanks for your update. 
 
Query 1: Okay, everything works now. I had the <EjsGrid> in a separate component. As a result, the events did not work properly.  
 
We have checked your query and tried to reproduce the issue, but it was unsuccessful. We have prepared a sample where we have used RowSelected event which works properly. We suggest you to use the latest nuget package (17.1.0.48-beta) version. Please refer the following code and sample link. 
 
[Index.razor] 
<EjsGrid id="Grid" DataSource="@gridData" AllowPaging="true" RowSelected="@rowselect"> 
    <GridPageSettings PageSize="5"></GridPageSettings> 
    <GridSelectionSettings PersistSelection="true"></GridSelectionSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Right" Width="120"></GridColumn> 
        .  .  .  . 
    </GridColumns> 
</EjsGrid> 
 
 
@functions { 
    public object gridData { get; set; } 
    protected override void OnInit() 
    { 
        gridData = OrdersDetails.GetAllRecords(); 
    } 
        public void rowselect(RowSelectEventArgs args) 
    { 
        System.Console.WriteLine(args.RowIndex); 
    } 
 
} 
 
 
 
Query 2: I have another question regarding licensing. Is it correct that all Syncfusion components can be used for free and without restrictions by private developers through a community license? And how do I know that I have the appropriate license key? 
 
We have checked and forwarded your query to sales team. We will update the further details as soon as possible. Also you can contact the sales team through this mail id: Sales@syncfusion.com  
 
Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon