This is a migrated thread and some comments may be shown as answers.

Currency Value

3 Answers 61 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yunuen Sanchez
Top achievements
Rank 1
Yunuen Sanchez asked on 02 Dec 2015, 05:22 AM

Hello, 

I would like to capture a currency value on a text field, I want the user to see it in a $ XXX.XX format. I tried to format the number using a Formatter but it didn't work:

var moneyFormatter = new NSNumberFormatter ();
moneyFormatter.NumberStyle = NSNumberFormatterStyle.Currency;

TKEntityProperty montoCobradoProperty = this.dataSource["MontoCobrado"];
montoCobradoProperty.HintText = "Monto Cobrado";
montoCobradoProperty.EditorClass = new Class (typeof(TKDataFormNumberEditor));
montoCobradoProperty.Validators = new NSObject[] { new NumberValidator() };
montoCobradoProperty.Formatter = moneyFormatter;

 

What am I doing wrong? is there any other way to achieve this request?

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 03 Dec 2015, 03:43 PM
Hi, Yunuen,

Thank you for writing.

The way you are trying to format the text field value is correct. I can confirm that the described issue appears in TKDataForm. It will be addressed in one of our future releases. I logged it in our feedback portal where you can follow its status. I also updated your Telerik points for reporting this issue.
If you need to display the property's value in currency format in read only mode you can subclass TKDataFormNumberEditor and override its Update() method to format the value. Please consider the code snippet below:
public class MyNumberEditor : TKDataFormNumberEditor
{
    NSNumberFormatter formatter = new NSNumberFormatter ();
 
    public MyNumberEditor () : base()
    {
        formatter.NumberStyle = NSNumberFormatterStyle.Currency;
    }
             
    public override void Update ()
    {
        base.Update ();
        this.TextField.Text = formatter.StringFromNumber((NSNumber)this.Property.ValueCandidate);
    }
}

If you have further questions, do not hesitate to contact us.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Yunuen Sanchez
Top achievements
Rank 1
answered on 03 Dec 2015, 09:23 PM
Thanks for the update Adrian! The code is working great.
0
Adrian
Telerik team
answered on 04 Dec 2015, 09:55 AM
Hello, Yunuen,

I am glad that I could help. 

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataForm
Asked by
Yunuen Sanchez
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Yunuen Sanchez
Top achievements
Rank 1
Share this question
or