This example shows how to create a simple dashboard in Runtime. First, create a new dashboard and add data source to the dictionary:
...
private StiReport CreateTemplate()
{
var report = StiReport.CreateNewDashboard();
var dashboard = report.Pages[0] as StiDashboard;
var data = new DataSet();
data.ReadXml("Data/Demo.xml");
report.RegData(data);
report.Dictionary.Synchronize();
...
Next, create table and fill it with data:
...
var tableElement = new StiTableElement();
tableElement.Left = 0;
tableElement.Top = 0;
tableElement.Width = 700;
tableElement.Height = 500;
tableElement.Border.Side = StiBorderSides.All;
tableElement.BackColor = Color.LightGray;
tableElement.Name = "Example";
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);
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);
...
After that, add table element to the dashboard:
...
dashboard.Components.Add(tableElement);
return report;
}
...
Then, use
buttonShow_click()
to show the dashboard:
...
private void buttonShow_Click(object sender, EventArgs e)
{
var dashboard = CreateTemplate();
dashboard.Show();
}
...
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen: