DataGrid - issue when adding @ref

I am trying to add @ref to a SfGrid. Getting an error when building. Any idea what I may missing here?

Thanks!

Screenshot 2022-02-14 184452.jpg


1 Reply

RN Rahul Narayanasamy Syncfusion Team February 15, 2022 05:08 AM UTC

Hi Oliver, 
 
Greetings from Syncfusion. 
 
Query: DataGrid - issue when adding @ref I am trying to add @ref to a SfGrid. Getting an error when building. Any idea what I may missing here? 
 
We suspect that you have not defined the Grid reference in @code section. You can resolve the reported problem by defining the Grid reference in @code section like below. Find the below code snippets for your reference. 
 
<SfGrid @ref="Grid" DataSource="@Orders" Toolbar=@Tool> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    SfGrid<Order> Grid; 
    public List<Order> Orders { get; set; } 
 
    .. .  
} 
 
Reference: 
 
Please let us know if you have any concerns. 
 
Regards, 
Rahul 


Loader.
Up arrow icon