コード例 #1
0
        /// <summary>
        /// Erweiterung der Popup-Menüs
        /// </summary>
        private void OnPopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            PivotGridField pivotGridField = e.HitInfo.HeaderField;

            if (pivotGridField != null)
            {
                // PivotSummaryType
                DXSubMenuItem summaryMenuItem = new DXSubMenuItem {
                    Caption = "Zusammenfassung", BeginGroup = true
                };
                e.Menu.Items.Add(summaryMenuItem);
                Dictionary <string, PivotSummaryType> summaryTypes = new Dictionary <string, PivotSummaryType>
                {
                    { "Summe", PivotSummaryType.Sum },
                    { "Durchschnitt", PivotSummaryType.Average },
                    { "Anzahl", PivotSummaryType.Count },
                    { "Minimum", PivotSummaryType.Min },
                    { "Maximum", PivotSummaryType.Max },
                };
                foreach (string key in summaryTypes.Keys)
                {
                    PivotSummaryType summaryType = summaryTypes[key];
                    DXMenuCheckItem  menuItem    = new DXMenuCheckItem {
                        Caption = key, Checked = pivotGridField.SummaryType == summaryType
                    };
                    menuItem.Click += delegate
                    { this.DuplicatePivotGridField(pivotGridField, summaryType, pivotGridField.SummaryDisplayType); };
                    summaryMenuItem.Items.Add(menuItem);
                }

                // PivotSummaryDisplayType
                DXSubMenuItem summaryDisplayMenuItem = new DXSubMenuItem {
                    Caption = "Anzeigen als"
                };
                e.Menu.Items.Add(summaryDisplayMenuItem);
                Dictionary <string, PivotSummaryDisplayType> summaryDisplayTypes = new Dictionary <string, PivotSummaryDisplayType>
                {
                    { "Standard", PivotSummaryDisplayType.Default },
                    { "Varianz zum Vorgänger (absolut)", PivotSummaryDisplayType.AbsoluteVariation },
                    { "Varianz zum Vorgänger (prozentual)", PivotSummaryDisplayType.PercentVariation },
                    { "Prozent vom Gesamt (Spalte)", PivotSummaryDisplayType.PercentOfColumn },
                    { "Prozent vom Gesamt (Zeile)", PivotSummaryDisplayType.PercentOfRow },
                    { "Prozent vom Gesamtergebnis (Spalte)", PivotSummaryDisplayType.PercentOfColumnGrandTotal },
                    { "Prozent vom Gesamtergebnis (Zeile)", PivotSummaryDisplayType.PercentOfRowGrandTotal },
                };
                foreach (string key in summaryDisplayTypes.Keys)
                {
                    PivotSummaryDisplayType summaryDisplayType = summaryDisplayTypes[key];
                    DXMenuCheckItem         menuItem           = new DXMenuCheckItem {
                        Caption = key, Checked = pivotGridField.SummaryDisplayType == summaryDisplayType
                    };
                    menuItem.Click += delegate { this.DuplicatePivotGridField(pivotGridField, pivotGridField.SummaryType, summaryDisplayType); };
                    summaryDisplayMenuItem.Items.Add(menuItem);
                }
            }
        }
コード例 #2
0
/// <summary>
/// Key DX classes
/// </summary>

        void PivotGridControl()
        {
            PivotGridControl pgc = new PivotGridControl();             // DX main control

            PivotGridField pgf = pgc.Fields[0];
            {
                PivotArea pga     = pgf.Area;               // location of field
                int       pgai    = pgf.AreaIndex;          // position within area
                bool      visible = pgf.Visible;            // true if really in an Area

                PivotGroupInterval pgi = pgf.GroupInterval; // Grouping enum (Mobius uses AggregationDef.GroupingType from GroupingTypeEnum)
                int pgiNr = pgf.GroupIntervalNumericRange;  // Numerical interval range (Mobius uses AggregationDef.NumericIntervalSize)

                PivotSummaryType pst = pgf.SummaryType;     // Summary type (Mobius uses AggregationDef.SummaryType from SummaryTypeEnum)
            }
        }
コード例 #3
0
        /// <summary>
        /// Dupliziert das angegebene Feld
        /// </summary>
        /// <param name="pivotGridField">das Feld, das dupliziert werden soll</param>
        /// <param name="summaryType">der Aggregattyp, der für das duplizierte Feld verwendet werden soll</param>
        /// <param name="summaryDisplayType">die Anzeige des Aggregattyps, der für das duplizierte Feld verwendet werden soll</param>
        private void DuplicatePivotGridField(PivotGridField pivotGridField, PivotSummaryType summaryType, PivotSummaryDisplayType summaryDisplayType)
        {
            PivotGridField duplicatedField = new PivotGridField(pivotGridField.Name + " " + summaryDisplayType + " " + summaryType, pivotGridField.Area);

            duplicatedField.Name                    = pivotGridField.Name + "-" + summaryDisplayType + "-" + summaryType;
            duplicatedField.Caption                 = (!String.IsNullOrEmpty(pivotGridField.Caption)) ? pivotGridField.Caption : pivotGridField.FieldName;
            duplicatedField.SummaryType             = summaryType;
            duplicatedField.SummaryDisplayType      = summaryDisplayType;
            duplicatedField.UnboundType             = pivotGridField.UnboundType;
            duplicatedField.UnboundExpression       = pivotGridField.UnboundExpression;
            duplicatedField.AllowedAreas            = pivotGridField.AllowedAreas;
            duplicatedField.FieldName               = pivotGridField.FieldName;
            duplicatedField.CellFormat.FormatType   = pivotGridField.CellFormat.FormatType;
            duplicatedField.CellFormat.FormatString = (summaryDisplayType.ToString().StartsWith("Percent")) ? "P" : pivotGridField.CellFormat.FormatString;

            this.Fields.Add(duplicatedField);
        }
コード例 #4
0
        public static void AddCustomTotal(PivotGridField field, PivotSummaryType sType, string tag, FormatType hFormatType,
                                          string hFormatString, FormatType cFormatType, string FormatStr)
        {
            if (field.TotalsVisibility != PivotTotalsVisibility.CustomTotals)
            {
                field.TotalsVisibility = PivotTotalsVisibility.CustomTotals;
            }

            PivotGridCustomTotal customTotal = new PivotGridCustomTotal(sType);

            field.CustomTotals.Add(customTotal);

            customTotal.Tag = tag;
            customTotal.Format.FormatType       = hFormatType;
            customTotal.Format.FormatString     = hFormatString;
            customTotal.CellFormat.FormatType   = cFormatType;
            customTotal.CellFormat.FormatString = FormatStr;
        }
コード例 #5
0
        public static bool AddCustomTotal(PivotGridControl gridControl, string fieldName,
                                          PivotSummaryType sType, string tag, FormatType hFormatType,
                                          string hFormatString, FormatType cFormatType, string FormatStr)
        {
            PivotGridField targetField;

            try
            {
                targetField = gridControl.Fields[fieldName];
            }
            catch
            {
                return(false);
            }

            if (targetField != null)
            {
                PivotGridHelper.AddCustomTotal(targetField, sType, tag,
                                               hFormatType, hFormatString, cFormatType, FormatStr);
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public ActionResult OnSaveFieldChanges
            (string caption, string captionEn, string aggregateFunctionId, string precision, string basicCountFunctionId, string adminUnitField, string dateField,
            string groupInterval, string addMissedValue, string startDate, string endDate)
        {
            AvrPivotGridModel model = GetModelFromSession();

            if (model == null)
            {
                return(new JsonResult
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = new { result = "error", error = m_ErrorMessage }
                });
            }
            if (model.PivotSettings.SelectedField != null)
            {
                WebPivotGridFieldClone clonedField =
                    model.PivotSettings.SelectedField.GetClonedField(model.PivotSettings.LayoutDataset, false);
                if (ModelUserContext.CurrentLanguage != Localizer.lngEn)
                {
                    clonedField.Caption = caption;
                }
                clonedField.CaptionEn               = captionEn;
                clonedField.AggregateFunctionId     = bv.common.Core.Utils.ToLong(aggregateFunctionId);
                clonedField.BasicCountFunctionId    = bv.common.Core.Utils.ToLong(basicCountFunctionId);
                clonedField.Precision               = bv.common.Core.Utils.ToNullableInt(precision);
                clonedField.UnitLayoutSearchFieldId = bv.common.Core.Utils.ToNullableLong(adminUnitField);
                clonedField.DateLayoutSearchFieldId = bv.common.Core.Utils.ToNullableLong(dateField);
                bool updateMissedValues = (!clonedField.AddMissedValues.Equals(bool.Parse(addMissedValue)) ||
                                           !clonedField.DiapasonStartDate.Equals(bv.common.Core.Utils.ToDateNullable(startDate)) ||
                                           !clonedField.DiapasonEndDate.Equals(bv.common.Core.Utils.ToDateNullable(endDate)) ||
                                           !clonedField.PrivateGroupInterval.Equals(bv.common.Core.Utils.ToNullableLong(groupInterval)));
                clonedField.PrivateGroupInterval = bv.common.Core.Utils.ToNullableLong(groupInterval);
                bool fillEmptyValues =
                    LayoutPivotGridHelper.IsFieldGroupIntervalChanged(model.PivotSettings.SelectedField,
                                                                      clonedField.PrivateGroupInterval.HasValue ? (PivotGroupInterval)clonedField.PrivateGroupInterval : model.PivotSettings.SelectedField.GroupInterval);
                clonedField.AddMissedValues   = bool.Parse(addMissedValue);
                clonedField.DiapasonStartDate = bv.common.Core.Utils.ToDateNullable(startDate);
                clonedField.DiapasonEndDate   = bv.common.Core.Utils.ToDateNullable(endDate);
                string error = ValidateFieldClone(clonedField, model.PivotSettings.SelectedField.IsDateTimeField);
                if (!string.IsNullOrEmpty(error))
                {
                    return(new JsonResult
                    {
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                        Data = new { result = "error", error = error }
                    });
                }
                bool aggregateChanged =
                    !model.PivotSettings.SelectedField.AggregateFunctionId.Equals(clonedField.AggregateFunctionId);
                model.PivotSettings.SelectedField.FlashChanges(model.PivotSettings.LayoutDataset);
                if (aggregateChanged)
                {
                    WebPivotGridField field           = model.PivotSettings.SelectedField;
                    CustomSummaryType summaryTypeType =
                        AvrPivotGridHelper.ParseSummaryType(model.PivotSettings.SelectedField.AggregateFunctionId);
                    field.SummaryDisplayType = PivotSummaryDisplayType.Default;

                    PivotSummaryType summaryType = summaryTypeType == CustomSummaryType.Count
                        ? PivotSummaryType.Count
                        : PivotSummaryType.Custom;
                    field.CustomSummaryType = summaryTypeType;
                    field.SummaryType       = summaryType;
                }
                if (model.PivotSettings.SelectedField.Action != WebFieldAction.Add)
                {
                    model.PivotSettings.SelectedField.Action = WebFieldAction.Edit;
                }
                model.PivotSettings.UpdatedField = model.PivotSettings.SelectedField;
                if (model.PivotSettings.SelectedField.HasChanges)
                {
                    model.PivotSettings.HasChanges = true;
                }
                if (updateMissedValues)
                {
                    LayoutPivotGridHelper.CopyMissedValuesFromField(model.PivotSettings.SelectedField, model.PivotSettings.Fields);
                    LayoutPivotGridHelper.AddMissedValues(model, true);
                }
                else if (fillEmptyValues)
                {
                    LayoutPivotGridHelper.FillEmptyValuesInDataArea(model);
                }
                if (model.PivotSettings.SelectedField.Action != WebFieldAction.Add)
                {
                    return(new JsonResult {
                        Data = String.Empty, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { result = "refresh", function = "RefeshData2" }
            });
        }