You can populate FlexPivot with data by binding the FlexPivotPage control with a data source. For this, you can use a data table or a data engine as the data source for binding to the FlexPivot. Let us discuss how you can bind the FlexPivot to a data table and a data engine in the following sections.
To bind the FlexPivot to a data table, follow these steps:
C# |
Copy Code
|
---|---|
//Establish connection to database and fetch data OleDbConnection oconn = new OleDbConnection(); oconn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\..\Documents\ComponentOne Samples\Common\C1NWind.mdb"; var da = new OleDbDataAdapter("select * from Invoices", oconn); |
C# |
Copy Code
|
---|---|
var dt = new DataTable(); da.Fill(dt); |
C# |
Copy Code
|
---|---|
flexPivotPage.FlexPivotPanel.C1PivotEngine.BeginUpdate(); flexPivotPage.DataSource = dt.DefaultView; flexPivotPage.FlexPivotPanel.C1PivotEngine.EndUpdate(); |
To bind the FlexPivot to a data table, follow these steps:
C# |
Copy Code
|
---|---|
//Establish connection to database and fetch data OleDbConnection oconn = new OleDbConnection(); oconn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\..\Documents\ComponentOne Samples\Common\C1NWind.mdb"; var da = new OleDbDataAdapter("select * from Invoices", oconn); |
C# |
Copy Code
|
---|---|
var dt = new DataTable(); da.Fill(dt); dt.TableName = "Invoices"; |
C# |
Copy Code
|
---|---|
string dataPath = Path.Combine(Directory.GetCurrentDirectory(), "Data"); //Storing DataEngine data flexPivotPage.FlexPivotPanel.Workspace.Init(dataPath); BindToDataEngine(); |
C# |
Copy Code
|
---|---|
//Import data in DataEngine datatable
C1.DataEngine.DbConnector.GetData(flexPivotPage.FlexPivotPanel.Workspace, dt.CreateDataReader(), dt.TableName);
|
C# |
Copy Code
|
---|---|
//Connect FlexPivot to DataEngine filled with data var fPanel = flexPivotPage.FlexPivotPanel; fPanel.C1PivotEngine.BeginUpdate(); fPanel.ConnectDataEngine(dt.TableName); fPanel.C1PivotEngine.EndUpdate(); |