protected void ASPxPivotGrid1_FieldAreaChanged(object sender, DevExpress.Web.ASPxPivotGrid.PivotFieldEventArgs e)
    {
        ASPxPivotGrid pivot = (ASPxPivotGrid)sender;

        pivot.OptionsChartDataSource.ProvideColumnGrandTotals = pivot.Fields.GetVisibleFieldCount(DevExpress.XtraPivotGrid.PivotArea.ColumnArea) == 0 ? true : false;
        pivot.OptionsChartDataSource.ProvideRowGrandTotals    = pivot.Fields.GetVisibleFieldCount(DevExpress.XtraPivotGrid.PivotArea.RowArea) == 0 ? true : false;
    }
Ejemplo n.º 2
0
        private static void PivotGridOnFieldAreaChanged(object sender, PivotFieldEventArgs pivotFieldEventArgs)
        {
            var pivotGrid              = (MVCxPivotGrid)sender;
            AvrPivotGridModel model    = GetModelFromSession(pivotGrid.Request);
            PivotGridField    field    = pivotFieldEventArgs.Field;
            WebPivotGridField webField = GetWebPivotGridFieldByName(model.PivotSettings.Fields, field.ID);

            if (field.Area == webField.Area && field.AreaIndex == webField.AreaIndex && field.Visible == webField.Visible)
            {
                return;
            }

            bool copyAddMissedValues = field.Visible &&
                                       (field.Area == PivotArea.ColumnArea || field.Area == PivotArea.RowArea) &&
                                       (!webField.Visible || !(webField.Area == PivotArea.ColumnArea ||
                                                               webField.Area == PivotArea.RowArea));
            bool clearMissedValues = !field.Visible ||
                                     !(field.Area == PivotArea.ColumnArea || field.Area == PivotArea.RowArea);

            webField.Area      = field.Area;
            webField.AreaIndex = field.AreaIndex;
            webField.Visible   = field.Visible;
            if (copyAddMissedValues)
            {
                CopyMissedValuesToField(webField, model.PivotSettings.Fields);
            }
            else if (clearMissedValues)
            {
                ClearMissedValues(webField);
            }
            var adminUnitsList = AvrPivotGridHelper.GetAdministrativeUnitView(model.PivotSettings.QueryId,
                                                                              model.PivotSettings.Fields.ToList <IAvrPivotGridField>());

            foreach (PivotGridField f in pivotGrid.Fields)
            {
                WebPivotGridField webF = GetWebPivotGridFieldByName(model.PivotSettings.Fields, f.ID);
                if (f.Visible && f.Area == field.Area && f.ID != field.ID)
                {
                    webF.AreaIndex = f.AreaIndex;
                }
                if (webF.UnitLayoutSearchFieldId != -1 && webF.UnitLayoutSearchFieldId != 0)
                {
                    if (adminUnitsList == null || adminUnitsList.Count == 0 || webF.Area != PivotArea.RowArea)
                    {
                        webF.UnitLayoutSearchFieldId = -1L;
                    }
                    else if (!webF.UnitLayoutSearchFieldId.Equals(adminUnitsList[0]["Id"]))
                    {
                        webF.UnitLayoutSearchFieldId = DBNull.Value.Equals(adminUnitsList[0]["Id"])
                                                           ? -1L
                                                           : (long)adminUnitsList[0]["Id"];
                    }
                }
            }
            if (model.PivotSettings.ShowMissedValues)
            {
                AddMissedValues(model, true);
                pivotGrid.JSProperties["cpNeedCallback"] = true;
                //pivotGrid.ReloadData();
            }
            else
            {
                LayoutValidateResult validateResult = FillEmptyValuesInDataArea(model);
                pivotGrid.JSProperties["cpNeedCallback"] = validateResult.IsCancelOrUserDialogCancel();
            }
            // because AvrPivotGridHelperWeb which used inside m_CustomSummaryHandler should be re-initialized
            m_CustomSummaryHandler = null;
        }