Hide/reset grandhild Datagrid

I have a master datagrid which i use to populate the child dtagrids on tabs in my page.

I also populate grandchild datagrids from each child

When i click a new row in the master, the children all reset but not the grandchildren.

How can i empty/hide the grandchild datagrid? I have tried setting the datasource of the grandchild=null when the rowselect event is called by the master but this throws an error.

Thanks

John

Hi @johnmu,

You can clear a data grid by setting the property it is bound to to an empty value e.g. Enumerable.Empty<ModelType>(). Something like this:

The DataGrid's Data property in this example is set to ${getOrdersResult}.

Morning,

When the code first runs and the grandhild datagrid has no elements it works fine
when i select the first child the grandchild populates correctly

But when i change row in the parent and 'set property.....Enumerable.Empty' is called i get this error:

I'ved tried wrapping this in a try catch clause but its not catching it in the C#

Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Sequence contains no elements

System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at EsWlite.Pages.AOpportunitiesMain.<BuildRenderTree>b__0_107(RenderTreeBuilder __builder8) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGrid1.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'x0Us35NtaeAAKW68KKWY6zVSYPZuEYgTJg94tktaspk'.

System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at EsWlite.Pages.AOpportunitiesMain.<BuildRenderTree>b__0_107(RenderTreeBuilder __builder8) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGrid1.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 25147.6865ms 101

Hi @johnmu,

You can try setting it to null instead. But make sure the Property type remains the same - IEnumerable. Alternatively use a bool property and set the Visible property of the data grid to ${grandChildVisible}. Then set that property to true or false as needed. This will completely hide the datagrid instead of displaying it empty.

Atanas,

Setting it to Null doesn't work either but hiding the datagrid is a viable solution.

Thanks as ever for your speedy support.

John