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# |
コードのコピー
|
---|---|
//データベースへの接続を確立し、データを取得します 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# |
コードのコピー
|
---|---|
var dt = new DataTable(); da.Fill(dt); |
C# |
コードのコピー
|
---|---|
flexPivotPage.FlexPivotPanel.FlexPivotEngine.BeginUpdate(); flexPivotPage.DataSource = dt.DefaultView; flexPivotPage.FlexPivotPanel.FlexPivotEngine.EndUpdate(); |
To bind the FlexPivot to a data table, follow these steps:
C# |
コードのコピー
|
---|---|
//データベースへの接続を確立し、データを取得します 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# |
コードのコピー
|
---|---|
var dt = new DataTable(); da.Fill(dt); dt.TableName = "Invoices"; |
C# |
コードのコピー
|
---|---|
string dataPath = Path.Combine(Directory.GetCurrentDirectory(), "Data"); //DataEngineデータを保存します flexPivotPage.FlexPivotPanel.Workspace.Init(dataPath); BindToDataEngine(); |
C# |
コードのコピー
|
---|---|
//DataEngineデータテーブルにデータをインポートします
C1.DataEngine.DbConnector.GetData(flexPivotPage.FlexPivotPanel.Workspace, dt.CreateDataReader(), dt.TableName);
|
C# |
コードのコピー
|
---|---|
//FlexPivotをデータが設定たされたDataEngineに接続します var fPanel = flexPivotPage.FlexPivotPanel; fPanel.FlexPivotEngine.BeginUpdate(); fPanel.ConnectDataEngine(dt.TableName); fPanel.FlexPivotEngine.EndUpdate(); |