Using Dashboard Variables in Code
Our sample projects and report templates can help you learn the basics of working with our products.Dashboard variables can be assigned from code before rendering — handy for passing application state into a template.
In React.
How it works. Values are set on the report before it is bound to the viewer, so the dashboard reflects the application's state.
In React.
import { Viewer, Stimulsoft } from "stimulsoft-dashboards-js-react/viewer";
function App() {
var report = new Stimulsoft.Report.StiReport();
report.loadFile("Dashboards/Variables.mrt");
report.setVariable("Name", "Andrew");
report.setVariable("Sex", true);
report.setVariable("BirthDay", Stimulsoft.System.DateTime.fromString("10.10.2010"));
return <Viewer report={report} />;
}report.setVariable(name, value)— assign each template variable by name before the viewer renders it.Stimulsoft.System.DateTime.fromString— build a date value for date variables.
How it works. Values are set on the report before it is bound to the viewer, so the dashboard reflects the application's state.