Example #1
0
        private void SetPivotGridData(DataTable dt, PivotGridControl pivotGrid)
        {
            XtraPivotGridHelper.DataViewTable dataTable = new XtraPivotGridHelper.DataViewTable();

            foreach (DataColumn info in dt.Columns)
            {
                dataTable.AddColumn(info.ColumnName, info.ColumnName, info.DataType, PivotArea.RowArea, null, null);
            }

            pivotGrid.BeginUpdate();
            pivotGrid.ClearPivotGridFields();
            pivotGrid.CreatePivotGridFields(dataTable);
            pivotGrid.DataSource = dt;
            pivotGrid.EndUpdate();
            if (dt.Rows.Count < 10000)
            {
                pivotGrid.BestFit();
            }
        }
Example #2
0
        private void CreatePivotGridView(MainView subView, string itemName, DataTable dt)
        {
            DockPanel dockPanel = subView.DockManager.AddPanel(DockingStyle.Float);

            dockPanel.DockedAsTabbedDocument = true;
            dockPanel.Text = "Pivot";
            dockPanel.Options.ShowCloseButton = false;

            PivotGridControl pivot = new PivotGridControl();

            XtraPivotGridHelper.DataViewTable pivotData = new XtraPivotGridHelper.DataViewTable();

            foreach (DataColumn dc in dt.Columns)
            {
                pivotData.AddColumn(dc.ColumnName, dc.ColumnName, dc.DataType, PivotArea.RowArea, null, null);
            }

            pivot.Dock = DockStyle.Fill;
            pivot.ClearPivotGridFields();
            pivot.CreatePivotGridFields(pivotData);
            pivot.DataSource = dt;
            //pivot.BestFit();
            dockPanel.Controls.Add(pivot);
        }