protected override IVisualBrick DrawHeaderBrick(PivotFieldItemBase field, Rectangle bounds) { IPivotPrintAppearance appearance = GetFieldAppearance(field); SetDefaultBrickStyle(appearance, CellSizeProvider.FieldValueTextOffset, 0, 0, 0); string text = field.Caption; IVisualBrick brick = CreateTextBrick(); brick.Text = text.Substring(MyPivotGridControl.ImagePlaceHolder.Length); if (text != null) { brick.TextValue = text; } brick.TextValueFormatString = ""; int imageIndex = ((PivotGridField)this.Data.GetField(field)).ImageIndex; if (imageIndex > -1) { ImageBrick ib = new ImageBrick(BorderSide.None, 0, Color.Red, Color.Transparent); ib.Image = ((ImageList)this.PivotGridControl.HeaderImages).Images[imageIndex]; int imageWidth = ib.Image.Width; int imageHeight = ib.Image.Height; ib.BackColor = brick.BackColor; ib.BorderColor = brick.BorderColor; brick.Sides = BorderSide.Top | BorderSide.Right | BorderSide.Bottom; ib.BorderStyle = brick.BorderStyle; ib.BorderWidth = brick.BorderWidth; ib.Sides = BorderSide.Top | BorderSide.Left | BorderSide.Bottom; ib.SizeMode = ImageSizeMode.CenterImage; //Graph.DrawBrick(ib, new Rectangle(bounds.X, bounds.Y + (bounds.Height - imageHeight) / 2, imageWidth, imageHeight)); Graph.DrawBrick(ib, new Rectangle(bounds.X, bounds.Y, imageWidth, bounds.Height)); Graph.DrawBrick(brick, new Rectangle(bounds.X + imageWidth, bounds.Y, bounds.Width - imageWidth, bounds.Height)); } else { Graph.DrawBrick(brick, new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height)); } brick.Separable = false; if (Owner != null) { if (Owner.CustomExportHeader(ref brick, field, appearance, ref bounds)) { ApplyAppearanceToBrickStyle(brick, appearance); } } return(brick); }
private void SetFieldSortBySummary(PivotFieldItemBase fieldItem, PivotFieldItemBase dataFieldItem, List <PivotGridFieldSortCondition> condition, bool sort) { //The following code can be used to access the actual PivotGridField object. The PivotFieldItem class is used to support asynchronous operations. //PivotGridField field = ((IPivotGridViewInfoDataOwner)pivotGridControl1).DataViewInfo.GetField(fieldItem); if (!fieldItem.CanSortBySummary) { return; } PivotGridField field = pivotGridControl1.Fields.GetFieldByName(fieldItem.Name); if (sort) { field.SortBySummaryInfo.FieldName = dataFieldItem.FieldName; field.SortBySummaryInfo.SummaryType = DevExpress.Data.PivotGrid.PivotSummaryType.Count; field.SortBySummaryInfo.Conditions.Clear(); field.SortBySummaryInfo.Conditions.AddRange(condition); } else { field.SortBySummaryInfo.Reset(); } }
protected override int CalculateHeaderHeight(PivotFieldItemBase field) { return(40); //return base.CalculateHeaderHeight(field); }
protected override DevExpress.XtraPrinting.IVisualBrick DrawHeaderBrick(PivotFieldItemBase field, System.Drawing.Rectangle bounds) { return(base.DrawHeaderBrick(field, bounds)); }
private static PivotGridSettings CreateLayoutPivotGridSettings(AvrPivotGridModel model) { var settings = new PivotGridSettings(); bool readOnly = model.PivotSettings.IsPublished | !AvrPermissions.UpdatePermission; settings.Name = "pivotGrid"; settings.CallbackRouteValues = new { Controller = "Layout", Action = "PivotGridPartial", //queryId = model.PivotSettings.QueryId, layoutId = model.PivotSettings.LayoutId }; settings.CustomActionRouteValues = new { Controller = "Layout", Action = "PivotGridPartial", //queryId = model.PivotSettings.QueryId, layoutId = model.PivotSettings.LayoutId }; settings.OptionsView.HorizontalScrollBarMode = model.PivotSettings.FreezeRowHeaders ? ScrollBarMode.Auto : ScrollBarMode.Hidden; if (model.PivotSettings.FreezeRowHeaders) { settings.Width = Unit.Percentage(99); } settings.OptionsView.ShowFilterHeaders = false; settings.OptionsView.ShowColumnHeaders = true; settings.OptionsView.ShowRowHeaders = true; settings.OptionsView.DataHeadersDisplayMode = PivotDataHeadersDisplayMode.Popup; settings.OptionsView.DataHeadersPopupMaxColumnCount = 3; //settings.OptionsDataField.RowHeaderWidth = 100; settings.OptionsPager.Position = PagerPosition.Bottom; settings.OptionsPager.RowsPerPage = BaseSettings.AvrRowsPerPage; // note: this option disables paging. commented by Ivan because of out of memory // settings.OptionsPager.Visible = false; settings.OptionsBehavior.BestFitMode = PivotGridBestFitMode.FieldValue; // PivotGridBestFitMode.Cell; settings.CustomLoadCallbackState = CustomLoadCallbackState; settings.OptionsCustomization.AllowDrag = !readOnly; settings.OptionsCustomization.AllowExpand = !readOnly; settings.OptionsCustomization.AllowDragInCustomizationForm = true; settings.OptionsCustomization.AllowHideFields = AllowHideFieldsType.Always; settings.OptionsCustomization.CustomizationFormStyle = CustomizationFormStyle.Simple; settings.OptionsCustomization.AllowCustomizationForm = !readOnly; SetTotalSettings(settings.OptionsView, model.PivotSettings); if (!readOnly) { settings.PivotCustomizationExtensionSettings.Name = "pivotCustomization"; settings.PivotCustomizationExtensionSettings.Enabled = true; settings.PivotCustomizationExtensionSettings.Visible = true; settings.PivotCustomizationExtensionSettings.AllowedLayouts = CustomizationFormAllowedLayouts.TopPanelOnly; settings.PivotCustomizationExtensionSettings.Layout = CustomizationFormLayout.TopPanelOnly; settings.PivotCustomizationExtensionSettings.AllowSort = true; settings.PivotCustomizationExtensionSettings.AllowFilter = false; settings.PivotCustomizationExtensionSettings.Height = Unit.Percentage(100); settings.PivotCustomizationExtensionSettings.Width = Unit.Percentage(100); } settings.OptionsCustomization.AllowPrefilter = false; settings.Prefilter.Enabled = false; settings.OptionsView.EnableFilterControlPopupMenuScrolling = true; settings.Prefilter.Criteria = CriteriaOperator.TryParse(model.PivotSettings.FilterCriteriaString); settings.Styles.PrefilterBuilderCloseButtonStyle.CssClass = "invisible"; settings.Styles.PrefilterBuilderHeaderStyle.CssClass = "roundbox"; settings.PopupMenuCreated += PopupMenuCreated; settings.Styles.PrefilterBuilderMainAreaStyle.CssClass = "filterwindow"; settings.FilterControlOperationVisibility = (sender, args) => { WebPivotGridField webField = GetWebPivotGridFieldByName(model.PivotSettings.Fields, args.PropertyInfo.PropertyName); if (webField == null) { args.Visible = false; return; } switch (webField.SearchFieldType) { case SearchFieldType.ID: //lookup args.Visible = IsValidLookupClause(args.Operation); break; case SearchFieldType.String: args.Visible = IsValidStringClause(args.Operation); break; case SearchFieldType.Date: args.Visible = IsValidDateClause(args.Operation); break; default: args.Visible = IsValidDefaultClause(args.Operation); break; } }; settings.FilterControlCustomValueDisplayText = (sender, args) => { if (args.Value == null) { args.DisplayText = Translator.GetMessageString("FilterConrol_EmptyEnter"); } else if (args.PropertyInfo.PropertyType == typeof(DateTime)) { args.DisplayText = string.Format("{0:d}", args.Value); } }; settings.OptionsCustomization.AllowFilterInCustomizationForm = true; settings.Theme = GeneralSettings.Theme; settings.Fields.Clear(); foreach (WebPivotGridField webField in model.PivotSettings.Fields.Where(f => f.Visible && f.Area != PivotArea.FilterArea).OrderBy(f => (long)f.Area * 100000 + f.AreaIndex)) { settings.Fields.Add(webField); } foreach (WebPivotGridField webField in model.PivotSettings.Fields.Where(f => !f.Visible || f.Area == PivotArea.FilterArea).OrderBy(f => f.Caption)) { settings.Fields.Add(webField); } settings.Init = (sender, args) => { var pivotGrid = (MVCxPivotGrid)sender; if (model.ShowingPrefilter) { pivotGrid.PrefilterCriteriaChanged += PrefilterCriteriaChanged; } pivotGrid.FieldAreaChanged += PivotGridOnFieldAreaChanged; pivotGrid.HeaderTemplate = new HeaderTemplate(model); }; settings.PreRender = (sender, e) => { var pivotGrid = (MVCxPivotGrid)sender; pivotGrid.BeginUpdate(); pivotGrid.HeaderTemplate = new HeaderTemplate(model); pivotGrid.EndUpdate(); }; settings.BeforeGetCallbackResult = (sender, e) => { var pivotGrid = (MVCxPivotGrid)sender; if (model.ShowPrefilter) { pivotGrid.IsPrefilterPopupVisible = true; CriteriaOperator criteria = CriteriaOperator.TryParse(model.PivotSettings.FilterCriteriaString); criteria = ValidatePrefilterCriteria(criteria); pivotGrid.Prefilter.Criteria = criteria; model.ShowPrefilter = false; model.ShowingPrefilter = true; return; } model.ShowingPrefilter = false; pivotGrid.BeginUpdate(); try { pivotGrid.Prefilter.Enabled = false; UpdatePivotGridField(pivotGrid, model); model.PivotSettings.UpdatedField = null; if (model.PivotSettings.UpdateGroupInterval) { PivotGroupInterval interval = GroupIntervalHelper.GetGroupInterval(model.PivotSettings.DefaultGroupInterval); SetInterval(pivotGrid, interval); model.PivotSettings.UpdateGroupInterval = false; } SetTotalSettings(pivotGrid.OptionsView, model.PivotSettings); pivotGrid.OptionsView.HorizontalScrollBarMode = model.PivotSettings.FreezeRowHeaders ? ScrollBarMode.Auto : ScrollBarMode.Hidden; if (model.PivotSettings.FreezeRowHeaders) { pivotGrid.Width = Unit.Percentage(99); } else { pivotGrid.Width = Unit.Empty; } pivotGrid.ReloadData(); } finally { pivotGrid.EndUpdate(); } }; //settings.ClientSideEvents.EndCallback = "layoutPivotGrid.resizePivotGridEvent"; settings.AfterPerformCallback = (sender, e) => { var pivotGrid = (MVCxPivotGrid)sender; if (pivotGrid.HeaderTemplate == null) { pivotGrid.HeaderTemplate = new HeaderTemplate(model); } //pivotGrid.BeginUpdate(); //pivotGrid.ReloadData(); //pivotGrid.EndUpdate(); }; settings.ClientSideEvents.CallbackError = "layoutPivotGrid.onCallbackError"; settings.ClientSideEvents.EndCallback = "layoutPivotGrid.onEndCallback"; settings.CustomCellDisplayText = (sender, e) => { InitDisplayTexthandler(); m_DisplayTextHandler.DisplayAsterisk(new WebPivotCellDisplayTextEventArgs(e)); if (e.DataField == null) { return; } if (model.PivotSettings.FieldsDictionary.ContainsKey(e.DataField.FieldName)) { WebPivotGridField field = model.PivotSettings.FieldsDictionary[e.DataField.FieldName]; m_DisplayTextHandler.DisplayCellText(new WebPivotCellDisplayTextEventArgs(e), field.CustomSummaryType, field.Precision); } }; settings.FieldValueDisplayText = (sender, e) => { InitDisplayTexthandler(); var eventArgs = new WebPivotFieldDisplayTextEventArgs(e); m_DisplayTextHandler.DisplayAsterisk(eventArgs); m_DisplayTextHandler.DisplayBool(eventArgs); if (m_CustomSummaryHandler == null) { var helper = new AvrPivotGridHelperWeb((ASPxPivotGrid)sender) { SingleSearchObject = model.PivotSettings.IsSingleSearchObject }; m_CustomSummaryHandler = new CustomSummaryHandler(helper); } var summaryTypes = new List <CustomSummaryType>(); List <IAvrPivotGridField> dataFields = AvrPivotGridHelper.GetFieldCollectionFromArea(model.PivotSettings.Fields, PivotArea.DataArea); foreach (IAvrPivotGridField field in dataFields) { summaryTypes.Add(field.CustomSummaryType); m_DisplayTextHandler.DisplayStatisticsTotalCaption(eventArgs, summaryTypes); } }; settings.CustomSummary = (sender, e) => { if (m_CustomSummaryHandler == null) { var helper = new AvrPivotGridHelperWeb((ASPxPivotGrid)sender); m_CustomSummaryHandler = new CustomSummaryHandler(helper); } WebPivotGridField settingsField = model.PivotSettings.Fields.Find(f => f.FieldName == e.DataField.FieldName); var field = e.DataField as IAvrPivotGridField; if (settingsField != null && field != null && ((int)field.CustomSummaryType <= 0)) { field.CustomSummaryType = settingsField.CustomSummaryType; field.BasicCountFunctionId = settingsField.BasicCountFunctionId; field.AggregateFunctionId = settingsField.AggregateFunctionId; field.UnitLayoutSearchFieldId = settingsField.UnitLayoutSearchFieldId; field.UnitSearchFieldAlias = settingsField.UnitSearchFieldAlias; field.SearchFieldDataType = settingsField.SearchFieldDataType; field.DefaultGroupInterval = settingsField.DefaultGroupInterval; field.Ordinal = settingsField.Ordinal; field.AddMissedValues = settingsField.AddMissedValues; field.DiapasonStartDate = settingsField.DiapasonStartDate; field.DiapasonEndDate = settingsField.DiapasonEndDate; field.Precision = settingsField.Precision; field.AggregateFunctionId = settingsField.AggregateFunctionId; field.BasicCountFunctionId = settingsField.BasicCountFunctionId; field.UnitLayoutSearchFieldId = settingsField.UnitLayoutSearchFieldId; field.UnitSearchFieldAlias = settingsField.UnitSearchFieldAlias; field.DateLayoutSearchFieldId = settingsField.DateLayoutSearchFieldId; field.DateSearchFieldAlias = settingsField.DateSearchFieldAlias; if (settingsField.IsDateTimeField) { field.GroupInterval = settingsField.DefaultGroupInterval; } field.AllowMissedReferenceValues = settingsField.AllowMissedReferenceValues; field.LookupTableName = settingsField.LookupTableName; field.GisReferenceTypeId = settingsField.GisReferenceTypeId; field.ReferenceTypeId = settingsField.ReferenceTypeId; field.LookupAttributeName = settingsField.LookupAttributeName; field.HaCode = settingsField.HaCode; field.AllPivotFields = settingsField.AllPivotFields; field.FieldNamesDictionary = settingsField.FieldNamesDictionary; } m_CustomSummaryHandler.OnCustomSummary(sender, new WebPivotGridCustomSummaryEventArgs(e)); }; settings.CustomCellStyle = (sender, args) => { var pivotGrid = (MVCxPivotGrid)sender; }; settings.HtmlCellPrepared = (sender, args) => { var pivotGrid = (MVCxPivotGrid)sender; }; settings.HtmlFieldValuePrepared = (sender, args) => { var pivotGrid = (MVCxPivotGrid)sender; }; settings.GridLayout = (sender, args) => { var pivotGrid = (MVCxPivotGrid)sender; model.PivotSettings.HasChanges = true; var fieldsToDelete = new List <PivotGridFieldBase>(); foreach (PivotGridField field in pivotGrid.Fields) { WebPivotGridField webField = GetWebPivotGridFieldByFieldName(model.PivotSettings.Fields, field.FieldName); if (webField != null) { PivotFieldItemBase visualField = pivotGrid.Fields.Data.VisualItems.Data.FieldItems.SingleOrDefault( s => s.FieldName == field.FieldName); Dbg.Assert(visualField != null, "field {0} is not found in pivot fields list", field.FieldName); if (!visualField.Visible && visualField.Area != PivotArea.FilterArea) { webField.Area = PivotArea.FilterArea; webField.AreaIndex = -1; webField.FilterValues.Clear(); webField.SortOrder = field.SortOrder; webField.Width = field.Width; ClearMissedValues(webField); } else { webField.Area = field.Area; webField.AreaIndex = field.AreaIndex; webField.Visible = field.Visible; webField.SortOrder = field.SortOrder; webField.Width = field.Width; webField.FilterValues.Assign(field.FilterValues); //if (webField.IsDateTimeField && webField.GroupInterval == PivotGroupInterval.Default) //{ // webField.DefaultGroupInterval = GroupIntervalHelper.GetGroupInterval(model.PivotSettings.DefaultGroupInterval); // field.GroupInterval = webField.GroupInterval; //} } } else { fieldsToDelete.Add(field); } } foreach (PivotGridFieldBase field in fieldsToDelete) { field.Visible = false; field.Area = PivotArea.FilterArea; field.AreaIndex = -1; pivotGrid.Fields.Remove(field); } //if (model.PivotSettings.ShowMissedValues) //{ // List<IAvrPivotGridField> fields = model.PivotSettings.Fields.Cast<IAvrPivotGridField>().ToList(); // AvrPivotGridHelper.AddMissedValuesInRowColumnArea(model, fields); //} if (fieldsToDelete.Count > 0) { pivotGrid.ReloadData(); } }; return(settings); }
protected override int CalculateHeaderHeight(PivotFieldItemBase field) { int baseHeight = base.CalculateHeaderHeight(field); return(Math.Max(baseHeight, imageHeight + 4)); }