Posted 31 January 2019, 2:03 am EST
Hello,
To add items like FlexGrid, FlexChart etc to the dashboard via code, you can make use of the Add method of the DashboardCollection class. The Add method accepts the id of the child container and a list of controls to place within the child container as parameters . These controls are then added to the child container/item container (Panel in case of Flow and Grid Layouts and C1SplitterPanel in case of Split Layout) which is created automatically by the Add method. For more information on this method please refer: https://help.grapecity.com/componentone/NetHelp/DashboardLayout/webframe.html#C1.Win.DashboardLayout.4~C1.Win.Layout.DashboardCollection~Add(String,IList).html
The code snippet shown below depicts how you can add the FlexGrid control to the Dashboard. Similar approach can be used to add other controls as well.
//Configure FlexGrid
C1FlexGrid grid = new C1FlexGrid();
grid.Dock = DockStyle.Fill;
grid.DataSource = salesData;
//Add child container containing FlexGrid
DashboardItem dashboardGridItem =dashboard.Items.Add(Guid.NewGuid().ToString(), new List<Control>(){grid});
dashboardGridItem.Caption = "Sales Details";
Panel gridChildContainer=(Panel)dashboardGridItem.ItemContainer;
gridChildContainer.Size = new Size(460, 300);
Also, please find attached a sample(“AddingControlsToDashboard.zip”) which demonstrates how you can add FlexChart, FlexGrid etc to the dashboard.
Hope it helps. Please let us know in case you have any other queries.
AddingControlsToDashboard.zip