Bug Report Q326025
Visible to All Users

PivotGrid module - CaptionForTrue and CaptionForFalse are not taken into account when displaying field values

created 14 years ago

Hi, I need change captions in PivotChart for a Boolean value.
How can I do it? I try to do it with CaptionsForBoolValues without success.
Attach image to show what I mean.
Thanks in advance
ALBERTO

Answers

created 14 years ago

Hello Alberto,
Currently, you should manually change these captions in ViewController using the PivotGridControl.FieldValueDisplayText and PivotGridControl.CustomCellDisplayText events, as shown below:

C#
public class Q326025Controller : ViewController<ListView> { private const string PivotGridListEditorKey = "PivotGridListEditor"; private void Q326025Controller_FieldValueDisplayText(object sender, PivotFieldDisplayTextEventArgs e) { string displayText = GetDisplayText(e.Field, e.Value); if(!string.IsNullOrEmpty(displayText)) { e.DisplayText = displayText; } } private void Q326025Controller_CustomCellDisplayText(object sender, PivotCellDisplayTextEventArgs e) { string displayText = GetDisplayText(e.DataField, e.Value); if(!string.IsNullOrEmpty(displayText)) { e.DisplayText = displayText; } } private PivotGridListEditor PivotGridListEditor { get { return View.Editor as PivotGridListEditor; } } protected virtual string GetDisplayText(PivotGridFieldBase field, object value) { if(field != null && value != null && value.GetType() == typeof(bool)) { IModelMember modelMember = View.Model.ModelClass.FindMember(field.FieldName); if(modelMember != null) { if((bool)value) { if(!string.IsNullOrEmpty(modelMember.CaptionForTrue)) { return modelMember.CaptionForTrue; } } else { if(!string.IsNullOrEmpty(modelMember.CaptionForFalse)) { return modelMember.CaptionForFalse; } } } } return null; } protected override void OnViewChanging(View view) { base.OnViewChanging(view); Active.RemoveItem(PivotGridListEditorKey); if(view is ListView) { Active[PivotGridListEditorKey] = ((ListView)view).Editor is PivotGridListEditor; } } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); ((PivotGridControl)(PivotGridListEditor.PivotGridControl)).CustomCellDisplayText += new PivotCellDisplayTextEventHandler(Q326025Controller_CustomCellDisplayText); ((PivotGridControl)(PivotGridListEditor.PivotGridControl)).FieldValueDisplayText += new PivotFieldDisplayTextEventHandler(Q326025Controller_FieldValueDisplayText); } protected override void OnDeactivated() { ((PivotGridControl)(PivotGridListEditor.PivotGridControl)).CustomCellDisplayText -= new PivotCellDisplayTextEventHandler(Q326025Controller_CustomCellDisplayText); ((PivotGridControl)(PivotGridListEditor.PivotGridControl)).FieldValueDisplayText -= new PivotFieldDisplayTextEventHandler(Q326025Controller_FieldValueDisplayText); base.OnDeactivated(); } }

We are going to fix this issue in the next XAF versions. I have converted your question to a bug report.
Thanks,
Anatol

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.