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

Paging is throwing an exception

I've pasted in a sample razor component. I've created a page which is using some simple grid features. The paging is not working though - I get the exception  crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Value cannot be null. (Parameter 'source') System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.Cast[Object](IEnumerable source) at Syncfusion.Blazor.Navigations.SfPager.EnsureDropdown() at Syncfusion.Blazor.Navigations.SfPager.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task).

Not sure what file types are supported, as I've tried to upload a plain text file with the sample code and it's not supported.

Here is the code I was using


@page "/trades"

@using BlazorLiquidity.Shared

@using Common.Models.DTOs

@using Microsoft.AspNetCore.SignalR.Client

@inject PortfolioHttpClient PortfolioHttpClient

@inject ILogger<PortfolioInstanceList2> Logger

@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.Cards

@using Syncfusion.Blazor.Buttons

@using Syncfusion.Blazor.Navigations

@using System.Text.Json

@using Common.Messages

@using Common.Models

@using Common.Models.Entities

@using ProtoBuf



<div id="ControlRegion2">

    <div class="container-fluid">

        <div class="row">

            <div class="col-md-12">



                    <div class="CustomHeader">

                        <h2>Trades</h2></div>

                    <SfGrid ID="Grid" DataSource="@_trades" @ref="Grid" Height="100%" Width="2400" AllowSorting="true" AllowFiltering="true" GridLines="GridLine.Both" AllowPaging="true">

                        <GridPageSettings PageSizes="20"></GridPageSettings>

                        <GridColumns>

                            <GridColumn Field=@nameof(TradeDTO.ExchangeTradeId) Visible="true" HeaderText="Trade Id" TextAlign="TextAlign.Left" Width="40"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.OrderId) Visible="true" HeaderText="Order Id" TextAlign="TextAlign.Left" Width="40"></GridColumn>



                            <GridColumn Field=@nameof(TradeDTO.InstanceName) Visible="true" HeaderText="Instance Name" Width="20"></GridColumn>

                            <GridColumn Field="CoinPair.Name" Visible="true" HeaderText="Coin Pair" TextAlign="TextAlign.Left" Width="25"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.IsBuy) Visible="true" HeaderText="IsBuy" Width="13"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.Price) Visible="true" HeaderText="Price" Width="20"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.Quantity) Visible="true" HeaderText="Quantity" Width="20"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.LeaveQuantity) Visible="true" HeaderText="Leave Quantity" Width="20"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.Fee) Visible="true" HeaderText="Fee" Width="20"></GridColumn>

                            <GridColumn Field=@nameof(TradeDTO.DateCreated) Visible="true" HeaderText="Date" Width="20"></GridColumn>

                        </GridColumns>

                    </SfGrid>


            </div>


        </div>

    </div>

</div>




@code {


    private List<SPDTO> _sps = new ();

    private int SPid { get; set; }

    private List<TradeDTO> _trades { get; set; } = new();

    SfGrid<TradeDTO>? Grid { get; set; }

    private bool _displayTrades = false;


    protected override async Task OnParametersSetAsync()

    {

        Console.WriteLine("In OnParametersSetAsync");

    }


    protected override async Task OnInitializedAsync()

    {

        int ExchangeTradeId = 1;

        int OrderId = 1;

        try

        {

           // _trades = await PortfolioHttpClient.GetAllTrades(11);

            for (int i = 0; i < 100; i++)

            {

                _trades.Add(new TradeDTO()

                {

                    ExchangeTradeId = ExchangeTradeId.ToString(),

                    OrderId = OrderId.ToString(),

                    VenueId = 2,

                    InstanceName = "Test1",

                  // Venue = new VenueDTO()

                  // {

                   // VenueName = "Binance"

                  // },

                    SPId = 11,

                // SP = new SPDTO()

                  // {

                  // Name = "VetLiquidation"

                  // },

                    IsBuy = false,

                    Price = 100.22m,

                    Quantity = 22,

                    LeaveQuantity = 10,

                    DateCreated = DateTime.UtcNow,

                    Fee = 1

                });

                ExchangeTradeId++;

            }

          // _sps = await PortfolioHttpClient.GetPortfolios();

        }

        catch (Exception e)

        {

            Console.WriteLine("Error retrieving Portfolios from d/b");

        }

    }


    public async Task HandleValidSubmit()

    {

        try

        {

            _displayTrades = true;

            _trades = await PortfolioHttpClient.GetAllTrades(SPid);

            StateHasChanged();


        }

        catch (Exception e)

        {

            Console.WriteLine($"What the hell is going on {e.Message} ");


        }



    }


}



1 Reply

PS Prathap Senthil Syncfusion Team December 12, 2022 10:57 AM UTC

Hi Conleth,

Greetings from Syncfusion support,

We created a simple sample based on your code snippet, but we could not reproduce the issue in our final version[20.3.0 .60]. Kindly refer to the attached sample for your reference.

If the reported issue persists, kindly share the following information with us so that we can validate the reported query and provide a solution as soon as possible.


  1. Share with us the entire Grid code snippet along with the model class.
  2. Share with us the NuGet version used.
  3. If possible, kindly share us the simple issue reproducible sample or modify the reported issue on the sample as mentioned above.


Regards,

Prathap S


Attachment: BlazorDataGrid_948fa595.zip

Loader.
Up arrow icon