Пример #1
0
        /// <summary>
        /// The area that a field is located in has changed.
        ///  If changed by the DX UI then the added members in PivotGridFieldMx must be updated
        ///  If changed by Mobius code (InSetup = true) then nothing needed here.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Grid_FieldAreaChanged(object sender, PivotFieldEventArgs e)
        {
            if (InSetup)
            {
                return;
            }

            try
            {
                InSetup = true;
                PivotGridFieldContext fc = GetPivotGridFieldContext(e.Field);
                if (fc == null)
                {
                    return;
                }

                PivotGridFieldMx f = fc.F;

                f.SyncMxRoleToDxArea();

                ResultsField rfld = fc.ResultsField;
                if (rfld == null || rfld.MetaColumn == null)
                {
                    return;
                }

                f.Aggregation.SetDefaultTypeIfUndefined(rfld.MetaColumn);                 // may need to set default type as well

                PivotGridControlMx.SetFieldCaption(f);

                PivotGrid.RefreshData();                 // recalc summaries

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

                return;
            }

            finally
            {
                InSetup = false;
            }
        }
Пример #2
0
/// <summary>
/// Build the Grid fields for the PivotGridControl from the persisted Mobius view fields
/// </summary>

        void BuildGridFieldsFromViewFields()
        {
            PivotGridFieldMx gf, gf2;

            PivotGridCtl.Fields.Clear();
            PivotGridCtl.Groups.Clear();

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            for (int fi = 0; fi < p.PivotFields.Count; fi++)             // build grid fields from view fields
            {
                PivotGridFieldMx pf   = p.PivotFields[fi];
                ResultsField     rfld = pf.ResultsField as ResultsField;
                if (rfld == null)
                {
                    continue;
                }
                PivotGridControlMx.SetFieldCaption(pf);                 // be sure we have a caption

                Mobius.Data.QueryColumn qc = rfld.QueryColumn;
                MetaColumn mc = rfld.MetaColumn;

                gf = new PivotGridFieldMx();
                pf.CopyField(gf);
                pf.SyncDxAreaToMxRole();

                if (mc.IsKey)
                {
                    gf.ImageIndex = (int)Bitmaps16x16Enum.Key;
                }
                else
                {
                    gf.ImageIndex = (int)mc.DataTypeImageIndex;
                }

                gf.Options.AllowRunTimeSummaryChange = true;
                gf.Options.ShowUnboundExpressionMenu = true;

                PivotGridCtl.Fields.Add(gf);
            }

            return;
        }
Пример #3
0
        /// <summary>
        /// Add a new field associated with specified ResultsField
        /// </summary>
        /// <param name="rfld"></param>
        /// <param name="Fields"></param>
        /// <param name="area"></param>
        /// <param name="visible"></param>
        /// <param name="pgi"></param>
        /// <returns></returns>

        internal static PivotGridFieldMx AddField(
            ResultsField rfld,
            List <PivotGridFieldMx> Fields,
            PivotArea area,
            bool visible,
            PivotGridGroup group,
            GroupingTypeEnum pgi)
        {
            QueryColumn qc = rfld.QueryColumn;
            MetaColumn  mc = qc.MetaColumn;
            QueryTable  qt = qc.QueryTable;

            PivotGridFieldMx f = new PivotGridFieldMx();

            if (mc.IsKey)
            {
                f.ImageIndex = (int)Bitmaps16x16Enum.Key;
            }
            else
            {
                f.ImageIndex = (int)mc.DataTypeImageIndex;
            }

            f.UnboundFieldName = qt.Alias + "." + mc.Name +       // identify by tableAlias.mcName (allows multiple instances of same metatable in query)
                                 "." + (UnboundFieldNameCount++); // and make unique in case used in multiple PivotGroupIntervals (needed?)

            f.ResultsField             = rfld;                    // store associated results field
            f.SummaryTypeMx            = SummaryTypeEnum.Count;
            f.Area                     = area;
            f.Visible                  = visible; // if not visible then put in list of unused fields
            f.Aggregation.GroupingType = pgi;

            PivotGridControlMx.SetFieldCaption(f);

            Fields.Add(f);

            if (group != null)
            {
                group.Add(f);                            // add to group
            }
            return(f);
        }