Hi,
I am trying to populate the pivotclient's datasource from a razor page model. I tried to convert the example to do this but I am stuck. Please help. See my attempt below:
/===============================================================
Index.cshtml@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<ej-pivot-client id="PivotClient1" title="Relational Browser" load="onload">
<e-data-source>
<e-pivot-rows>
<e-row-field field-name="Country" field-caption="Country"></e-row-field>
</e-pivot-rows>
<e-pivot-columns>
<e-column-field field-name="Product" field-caption="Product"></e-column-field>
</e-pivot-columns>
<e-pivot-values>
<e-value-field field-name="Amount" field-caption="Amount"></e-value-field>
</e-pivot-values>
</e-data-source>
</ej-pivot-client>
<script type="text/javascript">
function onload(args) {
args.model.dataSource.data = parseFromString(@Model.CubeData);
}
/===============================================================
Index.cshtml.cs public class IndexModel : PageModel
{
public string CubeData { get; private set; } = string.Empty;
public void OnGet()
{
CubeData = LoadData();
}
private string LoadData()
{
return "[{ Amount: 100, Country: \"Canada\", Date: \"FY 2005\", Product: \"Bike\", Quantity: 2, State: \"Alberta\" }]";
}
}
/===============================================================