Beispiel #1
0
/// <summary>
/// Calculate group value from incoming data value
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void Grid_CustomGroupInterval(object sender, PivotCustomGroupIntervalEventArgs e)
        {
            PivotGridFieldContext fc = GetPivotGridFieldContext(e.Field);
            PivotGridFieldMx      f  = fc.F;
            AggregationDef        ad = f.Aggregation;

            if (e.Field.Area != PivotArea.ColumnArea && e.Field.Area != PivotArea.RowArea)
            {
                return;                 // not sure why this is happening but ignore if so
            }
            if (!ad.IsGroupingType)     // must check this since when moving a field to a grouping area in the PivotGridDialog, this event fires before the FieldAreaChanged event (true?)
            {
                return;                 // throw new Exception("Expected Group Role");
            }
            AggregationTypeDetail td = ad.TypeDetail;

            if (td.GroupingMethod == null)
            {
                return;
            }

            QueryColumn qc = fc.Qc;
            object      vo = e.Value;        // value to apply group function to

            object groupValue = td.GroupingMethod(qc, ad, vo);

            e.GroupValue = groupValue;
        }
Beispiel #2
0
        /// <summary>
        /// Summary type selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void AggregationTypeMenuItem_Click(object sender, EventArgs e)
        {
            PivotGridFieldMx f = PivotGridField;

            DXMenuItem mi       = sender as DXMenuItem;
            string     typeName = mi.Tag.ToString();         // tag is enum member name

            AggregationTypeDetail atd = AggregationTypeDetail.GetByTypeName(typeName, true);

            if (atd.IsGroupingType && atd.GroupingType == GroupingTypeEnum.NumericInterval)
            {
                DialogResult dr = NumericIntervalDialog.ShowDialog(f.Aggregation, UIMisc.MousePosition);
                //if (dr == DialogResult.Cancel) return;
            }

            f.Aggregation.SetFromTypeName(typeName);
            f.SyncDxAreaToMxRole();             // sync Dx area
            PivotGrid.RefreshData();

            if (UpdateViewWhenGridControlChanges)
            {
                View.UpdateViewFieldsFromGridFields();
            }

            return;
        }
Beispiel #3
0
        /// <summary>
        /// Process aggregation item click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void AggregationTypeMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem mi = sender as ToolStripItem;

            if (mi.Tag == null)
            {
                return;                             // tag should contain internal AggregationType.Name
            }
            string aggTypeName        = mi.Tag.ToString();
            AggregationTypeDetail atd = AggregationTypeDetail.GetByTypeName(aggTypeName);

            if (atd == null)
            {
                throw new Exception("Unrecognized aggregation type: " + aggTypeName);
            }

            if (Qc.MetaColumn == null)
            {
                return;
            }

            if (Qc.MetaColumn.DataType == MetaColumnType.Structure ||
                Qc.MetaColumn.DataType == MetaColumnType.Image)
            {
                bool allowed = ((atd.Role == AggregationRole.DataSummary && atd.SummaryTypeId == SummaryTypeEnum.Count) ||
                                atd.Role == AggregationRole.Undefined);
                if (!allowed)
                {
                    MessageBoxMx.ShowError("Aggregation is not supported for this column");
                    return;
                }
            }

            if (atd.GroupingType == GroupingTypeEnum.NumericInterval)             // prompt for numeric interval
            {
                DialogResult dr = NumericIntervalDialog.ShowDialog(AggregationDef, UIMisc.MousePosition);
                if (dr != DialogResult.OK)
                {
                    return;
                }
            }

            AggregationDef.SetFromTypeName(aggTypeName);

            if (AggregationChangedDelegate != null)
            {
                AggregationChangedDelegate(this);
            }

            return;
        }
Beispiel #4
0
        /// <summary>
        /// Customize the display text for the cells displayed within the Data Area.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Grid_CustomCellDisplayText(object sender, PivotCellDisplayTextEventArgs e)
        {
            string txt;

            QualifiedNumber qn = e.Value as QualifiedNumber;             // summary values should be QNs

            if (qn == null)
            {
                return;
            }

            PivotGridFieldContext f = GetPivotGridFieldContext(e.DataField);

            AggregationTypeDetail atd = f.Aggregation.TypeDetail;

            if (atd == null || !atd.FractionalSummaryResult)
            {
                return;                                                          // just return if not numeric type
            }
            if (qn.IsNull)
            {
                e.DisplayText = "";
                return;
            }

            ColumnFormatEnum displayFormat = f.Qc.ActiveDisplayFormat;
            int decimals = f.Qc.ActiveDecimals;

            if (f.Mc.DataType == MetaColumnType.Integer)
            {
                displayFormat = ColumnFormatEnum.Decimal;
                decimals      = 1;
            }

            txt           = qn.Format(f.Qc, false, displayFormat, decimals, QnfEnum.Combined | QnfEnum.NValue, OutputDest.WinForms);
            e.DisplayText = txt;
            return;
        }