Completed
Last Updated: 01 Dec 2020 08:00 by ADMIN
Fernando
Created on: 24 Nov 2020 19:19
Category: TreeList
Type: Bug Report
1
When passing XField parameters with "null" value to TreeList component, it throws "ArgumentNullException: Value cannot be null. (Parameter 'name')"

If I pass XField parameters with a "null" value, it throws "ArgumentNullException: Value cannot be null. (Parameter 'name')" because it thinks the value is set, but apparently it does check if it's "null" before trying to "GetProperty".

 

Example, if any of these XField properties are null, it will throw the Exception

<TelerikTreeList Data="@Data"
                 IdField="@IdField"
                 ParentIdField="@ParentIdField"
                 HasChildrenField="@HasChildrenField"
                 ItemsField="@ItemsField">...</TelerikTreeList>

 

There should be a null check to ignore the use of that property in case it's null, otherwise, my code will need to be something like

 

@if (HasChildrenField != null && ItemsField != null)
{
    <TelerikTreeList Data="@Data"
                     IdField="@IdField"
                     ParentIdField="@ParentIdField"
                     HasChildrenField="@HasChildrenField"
                     ItemsField="@ItemsField">...</TelerikTreeList>
}
else if (HasChildrenField != null)
{
    <TelerikTreeList Data="@Data"
                     IdField="@IdField"
                     ParentIdField="@ParentIdField"
                     HasChildrenField="@HasChildrenField">...</TelerikTreeList>
}
else if (ItemsField != null)
{
    <TelerikTreeList Data="@Data"
                     IdField="@IdField"
                     ParentIdField="@ParentIdField"
                     ItemsField="@ItemsField">...</TelerikTreeList>
}

else

{

    <TelerikTreeList Data="@Data"
                     IdField="@IdField"
                     ParentIdField="@ParentIdField">...</TelerikTreeList>

}


Which isn't good.

 

At least "HasChildrenField" and "ItemsField" should have that check because it isn't a required parameter to have property for the TelerikTreeList  to work.

 

Error Stack

 

ArgumentNullException: Value cannot be null. (Parameter 'name')

  • System.Type.GetProperty(string name, BindingFlags bindingAttr)

  • System.Type.GetProperty(string name)

  • Telerik.Blazor.Extensions.ReflectionExtensions.GetPropertyValue(object target, string propertyName)

  • Telerik.Blazor.Data.TelerikTreeListDataSource<TItem>.CreateTreeListItem(TItem item, IEnumerable<TreeListItem<TItem>> childItems)

  • Telerik.Blazor.Data.TelerikTreeListDataSource<TItem>.GetItems(IEnumerable<TItem> data)

  • Telerik.Blazor.Data.TelerikTreeListDataSource<TItem>.BuildTree(IEnumerable<TItem> sourceData)

  • Telerik.Blazor.Data.TelerikTreeListDataSource<TItem>.InitData(IEnumerable<TItem> sourceData)

  • Telerik.Blazor.Data.TelerikTreeListDataSource<TItem>.ProcessData(IEnumerable data)

  • Telerik.Blazor.Components.Common.DataBoundComponent<TItem>.ProcessDataInternal()

  • Telerik.Blazor.Components.Common.DataBoundComponent<TItem>.OnParametersSetAsync()

  • Telerik.Blazor.Components.TelerikTreeList<TItem>.<>n__0()

  • Telerik.Blazor.Components.TelerikTreeList<TItem>.OnParametersSetAsync()

  • Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

  • Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

  • Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToPendingTasks(Task task)

  • Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

  • Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(ref DiffContext diffContext, int frameIndex)

  • Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(ref DiffContext diffContext, int frameIndex)

  • Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(ref DiffContext diffContext, int newFrameIndex)

  • Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(ref DiffContext diffContext, int oldStartIndex, int oldEndIndexExcl, int newStartIndex, int newEndIndexExcl)

  • Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, int componentId, ArrayRange<RenderTreeFrame> oldTree, ArrayRange<RenderTreeFrame> newTree)

  • Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

  • Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessPendingRender()

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)

  • Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()

  • Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()

  • Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

  • Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToPendingTasks(Task task)

  • Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

  • Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(int componentId, ParameterView initialParameters)

  • Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.CreateInitialRenderAsync(Type componentType, ParameterView initialParameters)

  • Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters)

  • Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext+<>c__11<TResult>+<<InvokeAsync>b__11_0>d.MoveNext()

  • Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.PrerenderComponentAsync(ParameterView parameters, HttpContext httpContext, Type componentType)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.PrerenderedServerComponentAsync(HttpContext context, ServerComponentInvocationSequence invocationId, Type type, ParameterView parametersCollection)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.RenderComponentAsync(ViewContext viewContext, Type componentType, RenderMode renderMode, object parameters)

  • Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)

  • Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, int i, int count)

1 comment
ADMIN
Svetoslav Dimitrov
Posted on: 01 Dec 2020 08:00

Hello,

This issue is resolved with our 2.20.0 release. In order to upgrade to our latest version (2.20.0 at the time of writing this), you can follow the upgrade procedure

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.