Declined
Last Updated: 29 Aug 2025 07:45 by ADMIN
Philip
Created on: 29 Aug 2025 01:29
Category: UI for Blazor
Type: Feature Request
0
Throw when using Data and OnRead for the same component issues

The latest version has broken one of our projects due to; 

  • Throw when using Data and OnRead for the same component

 

So we deliberately used both events which worked quite well (but is now disallowed);

 

<TelerikGrid Data="@SheetList"
     @ref="_grid"
     SelectionMode="@GridSelectionMode.Multiple"
     @bind-SelectedItems="@SelectedSheets"
     EditMode="GridEditMode.Inline"
     OnRowContextMenu="@OnContextMenu"
     OnRowClick="@OnRowClick"
     OnAdd="OnAddHandler"
     OnEdit="@OnEditHandler"
     OnUpdate="OnUpdateHandler"
     OnCreate="OnCreateHandler"
     OnDelete="OnDeleteHandler"
     OnRead="@(IsFromHierarchy ? null : OnReadItemsAsync)"

 

This pattern enabled us to create components that did EITHER server-side pagination, or if it was send a data list as a parameter from a parent component, then it would use that instead (and turn off server pagination).

 

What would now be the recommended pattern for this scenario? Or do we need to duplicate the whole grid in the component (which isnt ideal).

 

1 comment
ADMIN
Dimo
Posted on: 29 Aug 2025 07:45

Hello Philip,

Using Data and OnRead at the same time is not valid, recommended or supported since Telerik UI for Blazor version 3.0. We explicitly warn against this in our documentation.

In your case, you should only use OnRead with the following logic:

@using Telerik.DataSource.Extensions

<TelerikGrid TItem="@GridModel"
             OnRead="@OnReadItemsAsync" />


@code {
    [Parameter]
    public List<GridModel>? SheetList { get; set; }

    private async Task OnReadItemsAsync(GridReadEventArgs args)
    {
        if (SheetList is not null)
        {
            var localResult = await SheetList.ToDataSourceResultAsync(args.Request);
            args.Data = localResult.Data;
            args.Total = localResult.Total;
        }
        else
        {
            // Make a remote request to get the current page of items and populate the event argument properties.

            args.Data = new List<GridModel>();
            args.Total = 0;
        }
    }

    public class GridModel
    {

    }
}

 

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.