コード例 #1
0
        public static void Enable()
        {
            ENV.UI.Grid.AddToGridContext +=
                action =>
            {
                DevExpressIntegration.PivotGrid pg = null;
                FilterCollection fc   = null;
                bool             hide = false;
                var t   = Firefly.Box.Context.Current.ActiveTasks;
                var uic = t[t.Count - 1] as UIController;
                if (uic != null)
                {
                    action("Pivot - By Dev Express",
                           () =>
                    {
                        t = Firefly.Box.Context.Current.ActiveTasks;
                        if (t[t.Count - 1] == uic)
                        {
                            uic.SaveRowAndDo(
                                o =>
                            {
                                hide = false;
                                if (pg == null)
                                {
                                    fc = new FilterCollection();
                                    uic.Where.Add(fc);
                                    var dt = new DataTableBuilder()
                                    {
                                        SplitDateToYearMonthDay = true,
                                        SplitHourOutOfTime      = true
                                    };
                                    GridExports.ExportToDataTableBuilder(uic,
                                                                         () =>
                                    {
                                        pg = new DevExpressIntegration.PivotGrid();
                                        if (IsNotINMdi(uic.View))
                                        {
                                            pg.DisableFitToMDI();
                                        }
                                        pg.KeepViewVisible(false);

                                        pg.UserSelectedValue +=
                                            apply =>
                                        {
                                            fc.Clear();
                                            dt.ApplyFilter(apply, fc);
                                            o.ReloadData();
                                            //        o.GoToFirstRow();
                                            pg.KeepViewVisible(true);

                                            pg.Hide();
                                            hide = true;
                                        };
                                        pg.Run(dt.Result);
                                    }, dt);
                                }
                                else
                                {
                                    pg.KeepViewVisible(false);
                                    pg.ShowAfterHide();
                                }
                                if (!hide)
                                {
                                    pg.Dispose();
                                    pg = null;
                                    fc.Clear();
                                    //          o.GoToPreviouslyParkedRow();
                                    o.ReloadData();
                                }
                            });
                        }
                    });
                }
            };
        }