This example shows how to register data for dashboard template. First, you need to create a new dashboard:
...
private void buttonJson_Click(object sender, EventArgs e)
{
textBoxLog.Clear();
var report = StiReport.CreateNewDashboard();
textBoxLog.Text += "New dashboard created\r\n";
...
Next, use
Load()
method to load a template:
...
report.Load("Dashboards\\Dashboard.mrt");
textBoxLog.Text += "Dashboard template loaded\r\n";
...
After that, load a JSON file and get dataset from JSON file:
...
var jsonBytes = File.ReadAllBytes("Dashboards\\Demo.json");
textBoxLog.Text += "Load a JSON file\r\n";
var json = StiJsonConnector.Get();
var dataSet = json.GetDataSet(new StiJsonOptions(jsonBytes));
textBoxLog.Text += "Get DataSet from JSON file\r\n";
...
Then, register dataset object using
RegData()
:
...
report.Dictionary.Databases.Clear();
textBoxLog.Text += "Remove all connections from the dashboard template\r\n";
report.RegData("Demo", "Demo", dataSet);
textBoxLog.Text += "Register DataSet object\r\n";
report.Show(false);
textBoxLog.Text += "Show Dashboard\r\n";
}
...
In the screenshot below you can see the result of the sample code: