Ticket T1279758
Visible to All Users

How to use a custom function to localize month formatting in XRCrossTabCell

created 3 days ago (modified 2 days ago)

[DevExpress Support Team: CLONED FROM T1279152: XtraReport - Display overview of all found nested groups AFTER displaying the details for these nested groups]

Just note: I create the report definitions by C# code on my own but in case of troubles I can export it to WYSIWYG editor, find the solution and then to project found solution to my code.

My current result is this summary table:
Clipboard-File-1.png

Issue 2) The value in MONTH column has to be formatted like month name + year (like January 2025) but the month name must follow the language defined by the user running the report so I cannot use format string with generic MMMM. I have already defined my own custom function (based on ReportCustomFunctionOperatorBase) which can format DateTime properly based on "localization" object passed as one of the report parameters - but I don't know how to reference this custom function from the XRCrossTabCell.
Note: this "localization" parameter was omitted from the sample report but it could be imagined as some string value with the language code passed to the custom function.

The desired result is something like this:
Clipboard-File-2.png

Thank you very much. I know I have a lot of questions. :-)
M.

Answers approved by DevExpress Support

created 2 days ago

Hello Miroslav,

You can also use an expression to accomplish this task.

For this, use your custom function in the Text property's expression of the Month row field. Find my screencast demonstrating this in action.

Best regards,
Aleksandr

    Comments (1)

      Thank you again, setting the Text property's expression of the Month row field works, my custom function is called.
      I should make myself more familiar with the concept of expression bindings.

      My code:
      crossTab.Cells[0, 2].ExpressionBindings.Add(new("BeforePrint", "Text", "DateTimeToMonthNameAndYear(?Localization, [MESIC])"));

      where DateTimeToMonthNameAndYear is my custom function and Localization is a cross-tab parameter with some regional settings of the current user which allows me to return proper month name.

      But there is one problem with this solution - my custom function is called but the value of the first argument is not set so I will create new ticket with some sample project in C#.

      This ticket can be closed.

      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.