Grid do not refresh after data was loaded

Hi.

I have an SFgrid that pulls data from a SQL command that takes some time. After the query finishes and the dataset was loaded, the grid does not refresh and keeps empty. 

    <SfButton IsPrimary="true" @onclick="onToggleClick">Show Products</SfButton>

<SfGrid @ref="MemberProductGrid"

        DataSource="@memberproduct" @bind-Value="@memberproduct" EnableVirtualization="true"

        AllowSorting="true" AllowResizing="true" AllowFiltering="true" AllowPaging="true" AllowReordering="true"

        AllowExcelExport="true" EnablePersistence="true" ShowColumnChooser="true" ShowColumnMenu="true" AllowTextWrap="true"

        Toolbar="Toolbaritems"

        ContextMenuItems="@(new List<object>() {"AutoFit", "AutoFitAll", "SortAscending", "SortDescending","Copy", "ExcelExport", "CsvExport", "FirstPage", "PrevPage","LastPage", "NextPage"})">

    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>

    <GridPageSettings PageSize="30"></GridPageSettings>

    <GridEvents RowSelected="RowSelectHandler" OnToolbarClick="ToolbarClickHandler" TValue="MemberProduct" OnActionFailure="@ActionFailure" DetailDataBound="DetailDataBoundHandler_PriceGrid"></GridEvents>

    <GridTemplates>

        <DetailTemplate>

            @{ var vendorProduct = (context as MemberProduct);

                <SfGrid @ref="PriceGrid" TValue="VendorContractMarkups" AllowSorting="true" AllowResizing="true" EnablePersistence="true" AllowReordering="true">

                    <GridEvents Created="CreatedHandler_PriceGrid" TValue="VendorContractMarkups"></GridEvents>

                    <SfDataManager Url=@WebServiceUrl CrossDomain="true" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>

                    <GridPageSettings PageSize="10"></GridPageSettings>

                    <GridColumns>

                        <GridColumn Field="@nameof(VendorContractMarkups.Distributor)" HeaderText="Distributor" TextAlign="@TextAlign.Left" Width="80"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.Final_Price)" HeaderText="Final Price" Format="C2" TextAlign="@TextAlign.Left" Width="50"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.NextPrice)" HeaderText="Next Price" Format="C2" TextAlign="@TextAlign.Left" Width="50"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.NextPriceDate)" HeaderText="Next Price Date" TextAlign="@TextAlign.Left" Width="50"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.ProductCode)" HeaderText="Product Code" TextAlign="@TextAlign.Left" Width="80"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.Markup)" HeaderText="Markup %" TextAlign="@TextAlign.Left" Width="50"> </GridColumn>

                        <GridColumn Field="@nameof(VendorContractMarkups.Warehouse)" HeaderText="Warehouse" TextAlign="@TextAlign.Left" Width="80"> </GridColumn>

                    </GridColumns>

                </SfGrid>

            }

        </DetailTemplate>

    </GridTemplates>


    <GridColumns>

        <GridColumn Field="@nameof(MemberProduct.ContractDesc)" HeaderText="Contract Desc." TextAlign="@TextAlign.Left" Width="200" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.ContractNo)" HeaderText="Contract No." TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.VendorName)" HeaderText="Vendor Name" TextAlign="@TextAlign.Left" Width="300" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.Brand)" HeaderText="Brand" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.ProductDesc)" HeaderText="Product Desc." TextAlign="@TextAlign.Left" Width="400" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.ProductDescriptionV)" HeaderText="Product Desc.(V)" TextAlign="@TextAlign.Left" Width="200" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.VendorCode)" HeaderText="Vendor Code" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.GTIN)" HeaderText="GTIN" TextAlign="@TextAlign.Left" Width="100" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.Size)" HeaderText="Size(V)" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.Pkg)" HeaderText="Package" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.PackagingString)" HeaderText="Packaging String" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.ProductNote)" HeaderText="ProductNote" TextAlign="@TextAlign.Left" Width="300" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.GST)" HeaderText="GST/HST" TextAlign="@TextAlign.Left" Width="100" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.ProductNo)" HeaderText="Product No." TextAlign="@TextAlign.Left" Width="100" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.strStartDate)" HeaderText="Start Date" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.strEndDate)" HeaderText="End Date" TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

        <GridColumn Field="@nameof(MemberProduct.StockNo)" HeaderText="Stock No." TextAlign="@TextAlign.Left" Width="150" Visible="true"> </GridColumn>

    </GridColumns>



</SfGrid>


<SfDialog @ref="DialogWait" IsModal="true" Width="250px" ShowCloseIcon="true" Visible="false">

    <DialogTemplates>

        <Content> <SfSpinner Size="40" Label="Loading" Type="SpinnerType.Material" Visible="true"></SfSpinner></Content>

    </DialogTemplates>

</SfDialog>

@code {

  SfDialog DialogWait;

    private SfGrid<MemberProduct> MemberProductGrid;

    IEnumerable<MemberProduct> memberproduct;

private async void LoadProducts()

    {

         DialogWait.ShowAsync();
        memberproduct = await MemberProductService.MemberProductGetAll(session.MemberID, Servicelist, Filter, session.SessionID);

        DialogWait.HideAsync();
        MemberProductGrid.Refresh();


    }

}





Attachment: temp_11c2115f.rar

1 Reply

JP Jeevakanth Palaniappan Syncfusion Team September 21, 2021 06:31 AM UTC

Hi Leo, 

Greetings from Syncfusion support. 

We have checked your code and found that you have used void as return type for the async method. We suspect that the data is not loaded due to this. Also kindly confirm whether the data loaded for the second time when you change/load the data? 

It is recommend to use Task as the return type of async method. Find the below common links for more information. 

Reference

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon