Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWEdit - sample with pattern and regional settings
#1
Hi @all,

is there an example how to use

- the pattern-property (e.g. a regular expression)

- the regionalsettings-property (e.g. change decimal-point / thousand-separator)

in TIWEdit?

The samples on github are nice but don't use these properties.

By the way:

What is the placeholder-attribute for? As I understand it, there should also be a corresponding property placeholder-text.

Thanks in advance for hints!
The way to success is always under construction ... but i see a light at the end of the tunnel  Idea Big Grin
Reply
#2
1) Placeholder, if set, will use the hint of the edit control.

2) RegionalSettings is a public property of the ServerController and the Session. Each session inherits the same settings of the ServerController.RegionalSettings property, but can be configured independently.


By default, RegionalSettings is initialized using the same values for its sub-properties (e.g. decimal separator, thousands separator, etc.) as the Delphi standard FormatSettings.

Example of using a global (set at ServerController level) RegionalSettings. The same will apply to all sessions.

procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
  RegionalSettings.DecimalSeparator := ',';
  RegionalSettings.ThousandSeparator := '.';
  RegionalSettings.CurrencyString := 'NZD';
  RegionalSettings.CurrencyFormat := 2;    // currency symbol + a space are placed on the left side of the number. 
  RegionalSettings.ShowThousandSeparator := True;
end;


BTW, this is only valid when DataTypeOptions.NumberValidation = nvIntraWeb. When the value is nvBrowserNative, the browser will always use the local settings of the machine where the browser is.
Reply
#3
Hello Alexandre,

thanks for your reply. However, it doesn't work. According to your information:

procedure TTstServer.IWServerControllerBaseConfig(Sender: TObject);
begin
RegionalSettings.DecimalSeparator := ',';
RegionalSettings.ThousandSeparator := '.';
RegionalSettings.CurrencyString := 'NZD';
RegionalSettings.CurrencyFormat := 2; // currency symbol + a space are placed on the left side of the number.
RegionalSettings.ShowThousandSeparator := True;
end;

procedure TTstWindow.IWAppFormCreate(Sender: TObject);
begin
IWEdit1.DataType := stNumber;
IWEdit1.DataTypeOptions.FloatDP := 2;
IWEdit1.DataTypeOptions.NumberType := ntFloat;
IWEdit1.DataTypeOptions.NumberValidation := nvIntraWeb;
end;

When entering, no comma is possible.

I suggest extending the demo program on GitHub accordingly. The mistakes should become obvious.

Thanks in advance for checking and fixing.

Detlef
The way to success is always under construction ... but i see a light at the end of the tunnel  Idea Big Grin
Reply
#4
It does work for me as I mentioned.

The first edit is a float with 2 dp and the second is set to currency. Both work as expected.


Attached Files
.zip   CurrencyIWEdit.zip (Size: 52.13 KB / Downloads: 4)
Reply
#5
(04-27-2022, 06:01 AM)Alexandre Machado Wrote: It does work for me as I mentioned.

The first edit is a float with 2 dp and the second is set to currency. Both work as expected.

Hi Alexandre,

unfortunately I have the same problem reported by Detlef.
Clicking the comma doesn't have any effect even in your new test project.

If I try "123456" "comma" "99" the output is "12.345.699.00" and "NZD 12.345.699,00"
If I try "123456" "dot" "99" the output is "123.456.99" and "NZD 123.456.99,00"
And if you click on the field several times (or tab through the fields) a "00" is added to the output at every click.

Thanks
Fabrizio
Reply
#6
Thanks for your sample. But it doesn't work either!

It is not possible to enter a comma; even if DecimalChar is specified as a comma!

Find attached a corresponding screenshot.

So the left fields of your sample was entered with point instead of comma; the result after exit the fields is definitely wrong.

The right fields are defined as text and filled with

- IWEdit3.Text:=FormatFloat(    '#,##0.00', 8888.76);
- IWEdit4.Text:=FormatFloat('NZD #,##0.00', 5456.99);

and show the expected and correct result.

Am I wrong in my opinion?


Attached Files Thumbnail(s)
   
The way to success is always under construction ... but i see a light at the end of the tunnel  Idea Big Grin
Reply
#7
How's your client machine local settings configuration? What browser is this?

See attached image. On my machine, just typed 35 + comma and this is what I got


Attached Files Thumbnail(s)
   
Reply
#8
(04-27-2022, 09:44 AM)Fabrizio Conti Wrote:
(04-27-2022, 06:01 AM)Alexandre Machado Wrote: It does work for me as I mentioned.

The first edit is a float with 2 dp and the second is set to currency. Both work as expected.

Hi Alexandre,

unfortunately I have the same problem reported by Detlef.
Clicking the comma doesn't have any effect even in your new test project.

If I try "123456" "comma" "99" the output is "12.345.699.00" and "NZD 12.345.699,00"
If I try "123456" "dot" "99" the output is "123.456.99" and "NZD 123.456.99,00"
And if you click on the field several times (or tab through the fields) a "00" is added to the output at every click.

Thanks
Fabrizio


I did the same here and both worked as expected.

See attached image for the first case.

Regarding the second case, typing "123456" "dot" "99"  will indeed produce "NZD 123.456.99,00" because the dot is ignored

Can you please tell me your IW version, the browser that you are using and the local regional settings of your client machine (the one where the browser is installed)?


Attached Files Thumbnail(s)
   
Reply
#9
After banging my head against the wall for some time I found what's causing it.

It will be fixed in the next release

Thanks for the test case/report
Reply
#10
(04-28-2022, 04:20 AM)Alexandre Machado Wrote: After banging my head against the wall for some time I found what's causing it.

It will be fixed in the next release

Thanks for the test case/report

Would it be possible to add some RegionalSettings like Date and Time formatting?

I would be grateful if this could be done.

Cheers, Paul
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)