Ticket T1280007
Visible to All Users

Passing a non-simple type (POCO object) as a custom function parameter in XRCrossTabCell expression bindings

created 2 days ago

Hello Aleksandr.
This ticket is somewhat related to How to use a custom function to localize month formatting in XRCrossTabCell.

I have a XRCrossTab defined and I want to set up expression bindings for some of its cells to call my custom function called DateTimeToMonthNameAndYear. This function consumes two arguments - the first one is an object with ILocalization interface (so not a simple type), the second one is DateTime value.

The ILocalization object contains some regional settings of the current user and is passed to the report as its parameter.
This report parameter is then re-bound as the cross-tab parameter.
The custom function is called within the context of cross-tab as expected but the operand value is null.

If I try the same approach with the string value parameter (report parameter is bound to cross-tab parameter, proper custom function is called) then the parameter string value is available inside the custom function.

I have attached simple sample project to demonstrate the problem.

Interesting lines are:

Code
CustomFunctions.Register(new DateTimeToMonthNameAndYear()); // accepts ILocalization and DateTime CustomFunctions.Register(new MyStringFunction()); // accepts string value ... NewParameter(report, "Localization", typeof(ILocalization), Session); // the Session is object with ILocalization interface NewParameter(report, "MyStringValue", typeof(string), "OK_FOO_BAR"); // string value ... var crossTab = new XRCrossTab(); ... crossTab.Parameters.AddRange( [ new XRControlParameter("groupName", null, "IDPRACPOMER"), new XRControlParameter("MyStringValue", Report.Parameters["MyStringValue"]), // rebound parameter to cross-tab new XRControlParameter("Localization", Report.Parameters["Localization"]) // rebound parameter to cross-tab ]); ... crossTab.Cells[0, 2].ExpressionBindings.Add(new("BeforePrint", "Text", "'PARAM: ' + ?MyStringValue + '\nFUNC1: ' + MyStringFunction(?MyStringValue) + '\nFUNC2: ' + DateTimeToMonthNameAndYear(?Localization, [MESIC])")); // call custom functions

The current result is:
Clipboard-File-1.png
String value parameter (OK_FOO_BAR) can be referenced successfully both from XRLabel or from a custom function.
Object value parameter is not passed to the custom function so it cannot be used there (thus ERROR_NO_LOCALIZATION).

The expected result is to display OK_LOCALIZATION so the ILocalization object is available in my custom function.

What am I doing wrong?

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.