This example shows how to create a simple dashboard at runtime.
For example, let's create a dashboard with table. First, you need to add the
StiBlazorViewer
component to the view page.
@using Stimulsoft.Report.Blazor;
...
<StiBlazorViewer Report="@Report" />
...
Next, create a new dashboard object - use the
CreateNewDashboard()
method for this. After that, read and register data:
...
// Create dashboard Object
this.Report = StiReport.CreateNewDashboard();
var dashboard = this.Report.Pages[0] as StiDashboard;
// Read data
var dataPath = Path.Combine("Data/Demo.xml");
var data = new DataSet();
data.ReadXml(dataPath);
// Register data
this.Report.RegData(data);
this.Report.Dictionary.Synchronize();
...
Next, create a new
StiTableElement()
object, specify its position, size and fill it with data:
...
// Create table
var tableElement = new StiTableElement();
tableElement.Left = 0;
tableElement.Top = 0;
tableElement.Width = 700;
tableElement.Height = 500;
tableElement.Name = "Example";
// Fill table
var dataBase = new StiDimensionColumn();
dataBase.Expression = "Products.ProductID";
tableElement.Columns.Add(dataBase);
var dataBase1 = new StiDimensionColumn();
dataBase1.Expression = "Products.ProductName";
tableElement.Columns.Add(dataBase1);
var dataBase2 = new StiDimensionColumn();
dataBase2.Expression = "Products.UnitPrice";
tableElement.Columns.Add(dataBase2);
...
Then, apply filters:
...
// Apply filters
var filter1 = new StiDataFilterRule();
filter1.Condition = StiDataFilterCondition.BeginningWith;
filter1.Path = "Products.ProductID";
filter1.Value = "1";
tableElement.DataFilters.Add(filter1);
var filter2 = new StiDataFilterRule();
filter2.Condition = StiDataFilterCondition.EndingWith;
filter2.Path = "Products.UnitPrice";
filter2.Value = "1";
tableElement.DataFilters.Add(filter2);
...
Finally, add table to the dashboard:
...
// Add table to dashboard
dashboard.Components.Add(tableElement);
...
На скриншоте ниже Вы можете увидеть результат выполнения данного кода: