I'm trying to display a button in a grid based on whether data is present in a particular column. I've tried a couple variations, but don't think I have the correct syntax. So far I've attempted ${result.Count}>1 and ${result.Contains("AValue")}, and set the visibility property to one of these booleans. Any tips on setting something like this up?
Thanks guys, I've read through all that documentation, and I think my code is OK (I'm trying to use ${data.Enroute.Contains("Enroute")} ), however I'm getting the following error when trying to view my page:
dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at DonorTracker.Pages.ViewDonorTracker.<>c__DisplayClass0_0.b__4(RenderTreeBuilder __builder4)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at Radzen.Blazor.RadzenGrid1.<>c__DisplayClass0_3.<BuildRenderTree>b__28(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGridRow.<BuildRenderTree>b__0_0(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.CascadingValue1.Render(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()
dotnet: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'veJ5N8ZB3ZVQBRBuwqRrN97H60viZc3x9ntIU-r5I4Q'.
System.NullReferenceException: Object reference not set to an instance of an object.
at DonorTracker.Pages.ViewDonorTracker.<>c__DisplayClass0_0.b__4(RenderTreeBuilder __builder4)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at Radzen.Blazor.RadzenGrid1.<>c__DisplayClass0_3.<BuildRenderTree>b__28(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Radzen.Blazor.RadzenGridRow.<BuildRenderTree>b__0_0(RenderTreeBuilder __builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.CascadingValue1.Render(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()
Also the above error happens whenever I'm trying to access any method off ${data.field.AnyFunction()} like ${data.Enroute.ToUpper()} or ${data.Enroute.ToLower()}
This could happen if the Enroute property is null for some reason. Could this be the case? You can use the ?. operator which will make the method not execute if the property is null:
This would indeed happen because the Visible property is bool and the ?. expression evaluates to bool? (Nullable). Try ${data.PropertyName?.Contains("AValue") == true}