Pending Review
Last Updated: 14 Jan 2026 12:16 by Michal
Michal
Created on: 14 Jan 2026 12:16
Category: Grid
Type: Bug Report
0
Incorrect behaviour/order: OnStateInit and OnRead

Hello,

 there is inconsistency/behaviour/order in events of the Grid: OnStateInit and OnRead. Which leads to scenario with no clear sollution and would be nice to fix it, and how to solve it as "hotfix".
Also i think its not new in 12.x. release, it exists longer ;)


<TelerikGrid TItem="GData" @ref="gHL" OnRead=@GReadItems OnStateInit="@OnStateGHL"> ... <GridAggregates> @if(1==2){...} </GridAggregates> @code{ protected async Task GReadItems(GridReadEventArgs args) { **hack for C) if(gHL==null)return;//state init AVOID 2x call gread PRIOR OnStateInit

...// must be called: args.AggregateResults = rr.ToDataSourceResult(args.Request).AggregateResults;

... } void OnStateGHL(GridStateEventArgs<GData> args) //or async Task doesnt matter { //default SORTing:args.GridState = new GridState<GData> { SortDescriptors = new List<Telerik.DataSource.SortDescriptor> { new Telerik.DataSource.SortDescriptor{ Member = nameof(GData.DatPorizeni), SortDirection = Telerik.DataSource.ListSortDirection.Descending }, //new Telerik.DataSource.SortDescriptor{ Member = nameof(GData.Skupina), SortDirection = Telerik.DataSource.ListSortDirection.Ascending } } }; } }


Problematic scenarios, single page, same grid:

A) when NO aggregates markup EXISTS at all
1. OnStateInit
2. OnRead  - gHL IS NULL
=OK

B) when EMPTY aggregates markup EXISTS
1. OnRead
2. OnStateInit
=FAIL
HOW to read and ui data with correct STATE?
https://www.telerik.com/blazor-ui/documentation/components/grid/state

cannot call gHL.rebind, also gHL is null
NONE initinal "sorting,filtering etc" is set, WRONG data,columns,displayed to the user


C) when SOME real aggregates markup EXISTS
1. OnRead
2. OnStateInit
3. OnRead
=partial FAIL("**hack used"), but managed by if(gHL==null)return


D) "hotfix" used with  GridAggregates="@( HasAggregates ? GridAggregatesTemplate : null )"
act as A or C, but gHL is always null, which is also bad againts C)

Expected:
ALWAYS only A) - First 1.OnStateInit THEN 2.OnRead. its the best one, without any additional hacks = UNIFY the event orders and behaviour.
OR
A) or C)
everything else is unmanagable.
 Especially when initial sorting "is must" and aggregates,columns and so on, are managed by user(non static)
B) is completly WRONG: incorrect event order of OnStateInit and OnRead
D) is againts C) (cannot detect reference of gHL)

related to:
https://feedback.telerik.com/blazor/1654029-onstateinit-does-not-fire-if-gridaggregates-exists-but-is-empty

https://www.telerik.com/forums/grid-onstateinit-event-and-onread-event-chaos

OR how to solve it generally = what is the way to LOAD gridState, and after that, LOAD Data by defined GridState?

Thanks

0 comments