Exemplo n.º 1
0
        static void FillDatasetColumns(PivotGridControl pivot, DataTable dataTable1)
        {
            dataTable1.Columns.Add("RowFields", typeof(string));
            StringBuilder         sb = new StringBuilder();
            List <PivotGridField> fieldsInColumnArea = GetFieldsInArea(pivot, FieldArea.ColumnArea);

            bool multipleDataField = pivot.GetFieldsByArea(FieldArea.DataArea).Count > 1;

            for (int i = 0; i < pivot.ColumnCount; i++)
            {
                PivotCellBaseEventArgs pcea = pivot.GetCellInfo(i, 0);
                foreach (PivotGridField field in pcea.GetColumnFields())
                {
                    sb.AppendFormat("{0} | ", field.GetDisplayText(pcea.GetFieldValue(field)));//add formatting if it's necessary
                }
                if (multipleDataField)
                {
                    sb.AppendFormat("{0} | ", pcea.DataField);
                }
                if (pcea.ColumnValueType == FieldValueType.Value)
                {
                    sb.Remove(sb.Length - 3, 3);
                }
                else
                {
                    sb.Append(pcea.ColumnValueType.ToString());
                }
                dataTable1.Columns.Add(sb.ToString(), typeof(object));
                sb.Clear();
            }
        }
        private void CommandBinding_CanExecute_1(object sender, CanExecuteRoutedEventArgs e)
        {
            PivotCellBaseEventArgs cellInfo = pivotGridControl1.GetFocusedCellInfo();

            if (cellInfo.Value == null)
            {
                e.CanExecute = false;
            }
            else
            {
                e.CanExecute = true;
            }
        }
Exemplo n.º 3
0
        static void FillDatasetExtracted(PivotGridControl pivot, DataTable dataTable1)
        {
            List <object>         rowvalues       = new List <object>();
            string                tempRowText     = "";
            List <PivotGridField> fieldsInRowArea = GetFieldsInArea(pivot, FieldArea.RowArea);

            for (int i = 0; i < pivot.RowCount; i++)
            {
                PivotCellBaseEventArgs pcea = pivot.GetCellInfo(0, i);
                if (pcea.RowValueType == FieldValueType.Value)
                {
                    foreach (PivotGridField item in fieldsInRowArea)
                    {
                        tempRowText += pcea.GetFieldValue(item).ToString() + " | ";//add formatting if it's necessary
                    }
                    tempRowText = tempRowText.Remove(tempRowText.Length - 3, 3);
                }
                else
                {
                    tempRowText = pcea.RowValueType.ToString();
                }
                rowvalues.Clear();
                rowvalues.Add(tempRowText);
                tempRowText = "";
                for (int j = 0; j < pivot.ColumnCount; j++)
                {
                    pcea = pivot.GetCellInfo(j, i);
                    if (pcea.Value != null)
                    {
                        rowvalues.Add(pcea.Value);
                    }
                    else
                    {
                        rowvalues.Add(DBNull.Value);
                    }
                }
                dataTable1.Rows.Add(rowvalues.ToArray());
            }
        }
 bool IsGrandTotal(PivotCellBaseEventArgs e)
 {
     return(e.RowValueType == FieldValueType.GrandTotal ||
            e.ColumnValueType == FieldValueType.GrandTotal);
 }