Hey There,
I have a grouped Grid:
<SfGrid @ref="sfGridView" DataSource="@allElements" AllowGrouping="true" AllowPaging="true" AllowSorting="true" AllowTextWrap="true" AllowFiltering="false">
<GridPageSettings PageSize="20" />
<GridGroupSettings ShowDropArea="false" Columns="@InitialGrouping"></GridGroupSettings>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" Width="40" ></GridColumn>
......................
</GridColumn>
</GridColumns>
</SfGrid>
</Content>
And I'm trying to set the initially selected rows using the example here:
https://blazor.syncfusion.com/documentation/datagrid/selection/#multiple-selection-based-on-condition
However, this line throws an exception:
var records = await sfGridView.GetCurrentViewRecords();
System.InvalidCastException: Unable to cast object of type 'Syncfusion.Blazor.Data.Group`1[Models.LearningElement]' to type 'Models.LearningElement'.
at System.Linq.Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Syncfusion.Blazor.Grids.SfGrid`1.GetCurrentViewRecords()
at SpotOn.Base.SelectLearningElementDialogComponent.OnAfterRender(Boolean firstRender)
in Web.Solution\Blazor\Shared\Dialogs\SelectLearningElementDialog.razor.cs:line 144
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)