Hello, I am trying to display complex object models in a Pivot Table but am having trouble accessing child objects.
For example if I have the following:
<SfPivotView TValue="MultiOrderProduct" Height="900">
<PivotViewDataSourceSettings DataSource="@_dataSource" ExpandAll="true">
<PivotViewRows>
<PivotViewRow Name="ID"></PivotViewRow>
<PivotViewRow Name="ProductA"></PivotViewRow>
<PivotViewRow Name="ProductB"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="ID" Caption="Parent ID"></PivotViewValue>
<PivotViewValue Name="Price" Caption="ProductA Price"></PivotViewValue>
<PivotViewValue Name="Price" Caption="ProductB Price"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<MultiOrderProduct> _dataSource { get; set; } = new List<MultiOrderProduct>();
protected override void OnInitialized()
{
var product = new MultiOrderProduct()
{
ID = 0,
ProductA = new Product() { ProductName = "Shirt", Price = 20 },
ProductB = new Product() { ProductName="Coat", Price = 100 }
};
_dataSource.Add(product);
}
public class MultiOrderProduct
{
public int ID { get; set; }
public Product ProductA { get; set; }
public Product ProductB { get; set; }
}
public class Product
{
public string ProductName { get; set; }
public decimal Price { get; set; }
}
}
The pivot table is displaying only displaying the object name of ProductA and ProductB and also placing ProductB as a nested item under ProductA instead of the parent MultiOrderProduct.
How am I able to access and display child objects in a pivot table like this.
Thank you,