Declined
Last Updated: 16 Nov 2021 18:21 by ADMIN
Chris
Created on: 16 Nov 2021 10:22
Category: Grid
Type: Bug Report
1
usual way of accessing nested properties no longer works

Hi, 

I am using a grid on a data structure that has nested properties inside. Previously, I was able to do this which worked fine: (notice the first 2 colums)

              <TelerikGrid Data="@PackedInfo.PackedParts" Height="100%">
                    <GridColumns>
                        <GridColumn Field=@nameof(PackedPart.Part.PartNo) Title="Part no" />
                        <GridColumn Field=@nameof(PackedPart.Part.PartDescription) Title="Description" />
                        <GridColumn Field=@nameof(PackedPart.UnitWeightG) Title="Substance Weight" />
                        <GridColumn Field=@nameof(PackedPart.FlashPointCentigrade) Title="Flash point" />
                        <GridColumn Field=@nameof(PackedPart.Pg) Title="PG" />
                        <GridColumn Field=@nameof(PackedPart.Qty) Title="PG" />
                    </GridColumns>
                </TelerikGrid>

 

I recently upgraded to the latest version (Telerik.UI.for.Blazor (2.29.0) and noticed that the first 2 fields are no longer displaying. I fixed this, by specifying the field names as string values:


               <TelerikGrid Data="@PackedInfo.PackedParts" Height="100%">
                    <GridColumns>
                        <GridColumn Field="Part.PartNo" Title="Part no" />
                        <GridColumn Field="Part.PartDescription" Title="Description" />
                        <GridColumn Field=@nameof(PackedPart.UnitWeightG) Title="Substance Weight" />
                        <GridColumn Field=@nameof(PackedPart.FlashPointCentigrade) Title="Flash point" />
                        <GridColumn Field=@nameof(PackedPart.Pg) Title="PG" />
                        <GridColumn Field=@nameof(PackedPart.Qty) Title="PG" />
                    </GridColumns>
                </TelerikGrid>

I have also tried using @nameof(Part.PartNo) but that didn't work either. Only providing nested properties as string values works. This should not be the intended behaviour i'm sure? 

regards,

Chris Nateghi

1 comment
ADMIN
Marin Bratanov
Posted on: 16 Nov 2021 18:21

Hello Chris,

Using a plain string is the correct way to do this, the issue stems from the behavior of the nameof() method - it returns only the last field name, without the parent one. You can read more about this in the following article: https://docs.telerik.com/blazor-ui/knowledge-base/grid-bind-navigation-property-complex-object. This has always been the case since I wrote it in early 2019. Frankly, I am quite surprised that the nameof() approach has worked at all for your situation.

With that said, I must mark this as "declined" as it is not a bug in the component but a configuration matter stemming from the framework behavior (the way nameof() returns information).

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.