Blazor Syncfusion Grids: The Grid.CurrentViewData method always returns null

I am using Blazor Server and Syncfusion grids (SfGrid) to display information in multiple grids on a page.

My issue is after I access the grid referenced in the @ref attribute and I use the grid.CurrentViewData method, the resulting grid object is null.

=====example workflow======

The user indicates which items to save by using a checkbox column for each grid.

When I grab the grid during the save routine, to check which rows are checked, the grid is always null.

Here is my code.

@foreach(var item in items_to_display) 
    <SfGrid @ref=get_mygrid(item.name) DataSource="@Items" AllowTextWrap="true"  
                        AllowSorting ="false" AllowFiltering="false" AllowPaging="true" Width="100%" 
                        EnableAltRow="true" > 
                    <GridTextWrapSettings WrapMode="WrapMode.Content"></GridTextWrapSettings> 
                    <GridPageSettings PageSize=10></GridPageSettings>
                    <GridSelectionSettings  CheckboxMode="CheckboxSelectionType.ResetOnRowClick" 
                                CheckboxOnly="false" PersistSelection="true"></GridSelectionSettings>
                    <GridEvents TValue="Item" OnActionFailure="@ActionFailure"></GridEvents>
                    <GridColumns>
                        <GridColumn Field=@nameof(Item.Selected) Width="10px" >
                            <Template>
                                @{
                                    var item = (context as Item);
                                    <SfCheckBox Checked="item?.Selected"></SfCheckBox>
                                }
                            </Template>
                        </GridColumn>
                        <GridColumn Width="30px" Field=@nameof(Item.Group) HeaderText="Section"></GridColumn>
                        <GridColumn Width="10px" Field=@nameof(Item.ItemName) HeaderText="ITEM"></GridColumn>
                        <GridColumn Width="120px" Field=@nameof(Item.Description)  HeaderText="DESCRIPTION"> </GridColumn> 
                    </GridColumns>
                </SfGrid> 
     

My grid objects used in the @ref attribute in the grids...

private Dictionary<string, SfGrid<Items>> myGrids = new Dictionary<string, SfGrid<Items>>();
public SfGrid<Items> get_mygrid(string gridName)
{ 
    if (!(myGrids.Keys.Contains(gridName)) )
        myGrids.Add(gridName, new SfGrid<Item>()); 
    return myGrids[gridName];
}

I use the following code to try to access the grids, however it is always null.

foreach(var gridkey in myGrids.Keys)
{ 
    var grid = myGrids[gridkey].CurrentViewData as IEnumerable<object>;
    //=========grid is null here ===================
 }

You can use the dictionary items directly to the reference while rendering instead of using methods. We had modified the sample direct to access the mygrid variable. Kindly check the attached code snippet and sample for your reference.

<SfButton OnClick="clicked" Content="Click"></SfButton>

@foreach (var d in Data)

{

    <SfGrid DataSource="@Orders" @ref="myGrids[d]" AllowTextWrap="true" AllowSorting ="false" AllowFiltering="false" AllowPaging="true" Width="100%" EnableAltRow="true">

        <GridTextWrapSettings WrapMode="WrapMode.Content"></GridTextWrapSettings>

        <GridPageSettings PageSize=10></GridPageSettings>

        <GridColumns>

        </GridColumns>

    </SfGrid>

}

 

@code {

    public List<Order> Orders { get; set; }

    public List<string> Data = new List<string>() { "First", "second" };

    private Dictionary<string, SfGrid<Order>> myGrids = new Dictionary<string, SfGrid<Order>>();

 

    public void clicked()

    {

        foreach (var gridkey in myGrids.Keys)

        {

            var grid = myGrids[gridkey].CurrentViewData as IEnumerable<object>;

        }

    }

 

}

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGrid362229114.zip