PDA

View Full Version : Column value of child object



Ytterate
Sep 28, 2020, 2:29 PM
I have the following models:



<ext:Model runat="server" Name="Lot" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
</Fields>
</ext:Model>

<ext:Model runat="server" Name="Step" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="Lot" Type="Object" ModelName="Lot" />
</Fields>
</ext:Model>


I want to display the data from the child object (I've confirmed it is loaded) along-side the parent information. The only example I could find covering anything remotely like this was: https://examples5.ext.net/#/Form/Miscellaneous/Data_Binding/ which has `DataIndex="Phone.Home"`, but doing the same here doesn't work:



<Columns>
<ext:Column runat="server" Text="Name" DataIndex="Name" />
<ext:Column runat="server" Text="Lot" DataIndex="Lot.Id" />
</Columns>


I tried several variations, including things like:



<ext:ComponentColumn runat="server" Editor="true" Text="Lot" Sortable="false" DataIndex="Lot.Id">
<Component>
<ext:NumberField runat="server" MinValue="0" DataIndex="Id" />
</Component>
</ext:ComponentColumn>


With every combination of `DataIndex` in the `ComponentColumn` and `NumberField` tags that I could think of (none, `Lot`, `Id`, and `Lot.Id`).

How do you show nested data in a `GridPanel` column?

fabricio.murta
Oct 01, 2020, 8:46 PM
Hello @Ytterate!

Flattening the data to as single object with no children, server side, usually makes it much easier to handle the data at client side. But this examples depicts the scenario I believe you have at hand:

- Grid Panel > Data Presentation > Data Prepare (https://examples5.ext.net/#/GridPanel/Data_Presentation/Data_Prepare/)

Bear in mind you can clone the whole Examples Explorer project (https://github.com/extnet/examples.ext.net) at your site and build, search, change and experiment -- and build test case off examples. This may help you figure out a lot of issues you may encounter and get some nice ideas on approaches you could take in different scenarios.

Hope this helps!