Using RadZenGrid with Rest API

Hi folks, new to Blazor and the Radzen products, just trying to understand a few things. I am successfully using the Grid to load about 650 items from my API. Given there are quit e a few ways to use the grid, I was hoping for some insight on the best (efficient) way to use the Gird. I am using a very simple setup but have encountered something weird.

First, my API returns a simple JSON,

  {
    "id": 617,
    "domain": "cbc.ca",
    "name": "CBC"
  },

I use the below code to populate it. When I click on the Name column in order to filter, there's a 2-3 sec window before I can start typing. Then, when I am able to type, nothing happens, no filtering occurs, the busy icon appears and disappears but that's all. I used this example as a guide https://blazor.radzen.com/datagrid-simple-filter.

Any comments would be appreciated.

Thx

  <RadzenDataGrid Data="@_data" LoadData="LoadData" Count="@count" IsLoading="@isLoading" RowSelect="GridRowSelect" TItem="PublicationModel"
           AllowFiltering="true" AllowSorting="true" 
           Style="height:40em" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" 
          FilterMode="FilterMode.Simple" LogicalFilterOperator="LogicalFilterOperator.Or">
                <Columns>
                    <RadzenDataGridColumn TItem="PublicationModel" Property="Id" Title="ID" Width="5%" Filterable="false" />
                    <RadzenDataGridColumn TItem="PublicationModel" Property="Name" Title="Name" Width="30%" />
                    <RadzenDataGridColumn TItem="PublicationModel" Property="Domain" Title="Domain" Width="30%" />                                     
                </Columns>
   </RadzenDataGrid>


    int count;
    bool isLoading = false;
    IEnumerable<PublicationModel>? _data;

    async Task LoadData()
    {
        isLoading = true;

        _data = await PublicationService.List();
        count = _data.Count();

        isLoading = false;
    }


Hi @TimCadieux,

When using the LoadData event you should perform the filtering by using its event arguments. You can check the LoadData example for some ideas.

That did fix the issue, thank you. Not sure how efficient this casting is though.

async Task LoadData(LoadDataArgs? args)
{
    isLoading = true;

    _data = await ArticleTypeService.List();

    if (!string.IsNullOrEmpty(args.Filter))
    {
        var resp = _data.AsQueryable();
        resp = resp.Where(args.Filter);

        _data = resp.ToList();
    }

    if (!string.IsNullOrEmpty(args.OrderBy))
    {
        var resp = _data.AsQueryable();
        resp = resp.OrderBy(args.OrderBy);

        _data = resp.ToList();
    }

    count = _data.Count();

    isLoading = false;
}