Ticket T352836
Visible to All Users

Custom Decimal Property Editor not invoked when Currency value is changed

created 9 years ago (modified 9 years ago)
C#
[PropertyEditor(typeof(decimal),false)] public class CustomCurrencyDecimalPropertyEditor : DecimalPropertyEditor { public CustomCurrencyDecimalPropertyEditor(Type objectType, IModelMemberViewItem info) : base(objectType, info) { } protected override void SetupRepositoryItem(RepositoryItem item) { base.SetupRepositoryItem(item); RepositoryItemDecimalEdit DecimalProperty = (RepositoryItemDecimalEdit)item; DecimalProperty.Buttons[0].Visible = false; try { var CurrentObject = View.CurrentObject; Type CurrentObjectType = CurrentObject.GetType(); Currency Currency = (Currency)CurrentObjectType.GetProperty("Currency").GetValue(CurrentObject); DecimalProperty.Mask.Culture = CultureInfo.GetCultureInfo(Currency.Culture.CultureID); DecimalProperty.DisplayFormat.Format = DecimalProperty.Mask.Culture.NumberFormat; } catch(Exception Ex) { } } }

I have a currency and amount fields in a screen. The amount fields should be formatted based on the currency selected. I have created a custom decimal property editor for this. The editor works fine when the screen is opened freshly. But when the screen is in edit mode, when the currency is changed , the editor is not being invoked and so the amount field is not formatted based on the current currency. I have applied immediatePostData for currency field in the screen. Can you please  help to find out what I am missing here. Thanks in Advance.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello Kanagu,

The SetupRepositoryItem property is called only once, when the editor is created. To update the editor settings when the Currency property is changed, you can implement the IDependentPropertyEditor interface in your Property Editor.
Please let me know if you need further assistance.

    Show previous comments (14)
    KD KD
    Kanagu Duraiswamy 9 years ago

      Thanks. It solved the issue.

      How to set the AspxTextBox editors mask property based on a culture. I tried as below,

      C#
      DecimalPropertyEditor.MaskSettings.Mask = String.Format("{0}<0..99999g>.<{1}..{2}>", CurrentCulture.NumberFormat.CurrencySymbol, new String('0', CurrentCulture.NumberFormat.CurrencyDecimalDigits), new String('9', CurrentCulture.NumberFormat.CurrencyDecimalDigits));

      But it uses only DecimalDigits and Currency Symbol and thus incomplete. I would like to mask the input entirely based on the selected culture(Culture can be selected from the drop down) as I did in the Winforms solution using the below code, so that the windows solution and win solution is in synch

      C#
      DecimalProperty.Mask.Culture = CultureInfo.GetCultureInfo(Currency.Culture.CultureID); //To format the currency and numeric fields based on the number format designed for the culture chosen DecimalProperty.DisplayFormat.Format = DecimalProperty.Mask.Culture.NumberFormat;

      Is it possible?

      Thanks

      Anatol (DevExpress) 9 years ago

        I've created a separate ticket for this task and forwarded it to our ASP.NET team: T404423: ASPxTextBox - How to change the currency mask dynamically based on the selected culture. It has been placed in our processing queue and will be answered shortly.

        KD KD
        Kanagu Duraiswamy 9 years ago

          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.