BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
Hi!
My Pivotview is showing 'no records' even for sample data, as given on Syncfusion demo page. https://blazor.syncfusion.com/documentation/pivot-table/getting-started?cs-save-lang=1&cs-lang=csharp
Have added nugets, added to MainLayout, & _Imports.razor file.
imported in page:
@using Syncfusion.Blazor
@using Syncfusion.Blazor.PivotView
My Page code:
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@dataSource">
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> dataSource { get; set; }
protected override void OnInitialized()
{
this.dataSource = ProductDetails.GetProductData().ToList();
}
public class ProductDetails
{
public int Sold { get; set; }
public double Amount { get; set; }
public string Country { get; set; }
public string Products { get; set; }
public string Year { get; set; }
public string Quarter { get; set; }
public static List<ProductDetails> GetProductData()
{
List<ProductDetails> productData = new List<ProductDetails>();
productData.Add(new ProductDetails { Sold = 31, Amount = 52824, Country = "France", Products = "Mountain Bikes", Year = "FY 2015", Quarter = "Q1" });
.....
productData.Add(new ProductDetails { Sold = 99, Amount = 345860, Country = "United States", Products = "Road Bikes", Year = "FY 2017", Quarter = "Q4" });
return productData;
}
}
}
Hi Vishal,
Thank you for sharing the code example. We reviewed it and found that you
haven’t bound any fields to the row, column, or value axes of the pivot table.
We want to clarify that pivot tables are intended to display aggregated values
based on combinations of rows, columns, and values. More importantly, the value
axis is crucial for the pivot table to present meaningful data. Therefore, you
need to bind at least one field to the value axis using the PivotViewValues
property in the
PivotViewDataSourceSettings
class
to render the pivot table with data. Additionally, if you would like to add
fields to the row and column axes, you can use the PivotViewRows
and PivotViewColumns
properties,
respectively. Please refer to the code example below.
Code example:
<SfPivotView TValue="ProductDetails" Height="300"> <PivotViewDataSourceSettings DataSource="@dataSource"> <PivotViewColumns> <PivotViewColumn Name="Year"></PivotViewColumn> <PivotViewColumn Name="Quarter"></PivotViewColumn> </PivotViewColumns> <PivotViewRows> <PivotViewRow Name="Country"></PivotViewRow> <PivotViewRow Name="Products"></PivotViewRow> </PivotViewRows> <PivotViewValues> <PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue> <PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue> </PivotViewValues> </PivotViewDataSourceSettings> </SfPivotView> |
Output screenshot:
Additionally, we have prepared a sample for your reference. Please find it in
the attachment below.
Moreover, we have provided the documentation link for more information on how
to add fields to row, column, value, and filter axes.
Document: https://blazor.syncfusion.com/documentation/pivot-table/getting-started?cs-save-lang=1&cs-lang=csharp#adding-fields-to-row-column-value-and-filter-axes
Please let us know if you have any concerns.
Regards,
Sridhar Karunakaran
Thanks Sridhar for providing such a clear solution with example and all!
Was really wonderful of you.
Hi Vishal,
Thank you for your update. We are delighted to hear that you are satisfied with the solution we have provided. If you have any further questions or need assistance, please contact us. We are here to help!
Best regards,
Sridhar Karunakaran