Hi…
Have been working with your Dashboard and is quite impressed with it ́s features - however a problem has shown itself here.
I ́ve made a Dashboard who gets it ́s data from sql-server, and saved it ́s layout, and upon loading, it is shown perfectly.
But then I wanted to be able to add a "filter" or criteria based on user selected category. This gives me some problems :-(
ìve put a splitcontainer control with a grid on the one side, and the dashboard on the other, and my plan was when the user selected a row in the grid, the dashboard would be updated with the selection as criteria / filter.
I ́ve loaded the new data into a datatable/dataset, but when I try to put this in the dashboards data with the command:
Me.DashboardViewer1.Dashboard.DataSources(0).Data = Data
I keep getting the error: "Data cannot be assigned if a data provider is used" and this I do not understand, as it is a table from the same sql-database table, only with data reflecting what the user selected (only one group not all as is loaded when the form is shown)
Then I tried another approach to get the job done:
Me.DashboardViewer1.Dashboard.DataSources.Clear()
Me.DashboardViewer1.Dashboard.AddDataSource("Data", Ds.Tables("Datatabel"))
And this didn ́t produce any errors, but i neither produced any data in the dashboard, as all items were cleared and showed nothing anymore.
Is the datasource for Dashboard static, or is there a way that I can provide new data for the dashboard ? Or is there a way that I can (through code) can pass a filter to the viewer, like ActiveFilterstring in Gridview, i.e. "Group=1"
Hope you can help me
Regards,
Michael
PS. Have applied update/build with the fix with the ability to enter user/password for the sql-server datasource upon loading - and this was wonderfull :-)
Change data in Dashboard
Answers approved by DevExpress Support
Hi Michael,
Thank you for your kind words. I am happy to hear that you have found this fix helpful.
To update data within a dashboard item, assign a new data source to its DataSource property after you update the Dashboard.DataSources collection.
I have attached an example that shows how to do this.
Please also note that we have added the DashboardViewer.ReloadData method that allows you to accomplish this with a single call.
You can get a public fix that contains this method from the following page right now:
Usability - There is no public API for reloading data from database
Thanks,
Basil
Thank you for your suggestion. We appreciate your input. We will take your comments into account when scheduling our development.
With the current dashboard version, it is possible to accomplish this task without additional event handlers. You can use the following code:
C#dashboardDesigner.OpenDashboard("test.xml");
dashboardDesigner.Dashboard.DataSources.FindFirst(ds => ds.Name == "DS").Data = data;
or
C#Dashboard dashboard = new Dashboard();
dashboard.LoadFromXml("test.xml");
dashboard.DataSources.FindFirst(ds => ds.Name == "DS").Data = data;
dashboardDesigner.Dashboard = dashboard;
Note that in the latter case, it is necessary to dispose of the Dashboard manually.
This behavior with cell alignment looks like a bug. So, I have registered a separate report: Dashboard Grid numeric cells have incorrect left alignment