Atozed Forums
TIWEdit - sample with pattern and regional settings - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: TIWEdit - sample with pattern and regional settings (/thread-2700.html)

Pages: 1 2


TIWEdit - sample with pattern and regional settings - Lorbass - 04-05-2022

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!


RE: TIWEdit - sample with pattern and regional settings - Alexandre Machado - 04-09-2022

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.


RE: TIWEdit - sample with pattern and regional settings - Lorbass - 04-24-2022

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


RE: TIWEdit - sample with pattern and regional settings - Alexandre Machado - 04-27-2022

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.


RE: TIWEdit - sample with pattern and regional settings - Fabrizio Conti - 04-27-2022

(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


RE: TIWEdit - sample with pattern and regional settings - Lorbass - 04-27-2022

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?


RE: TIWEdit - sample with pattern and regional settings - Alexandre Machado - 04-27-2022

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


RE: TIWEdit - sample with pattern and regional settings - Alexandre Machado - 04-27-2022

(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)?


RE: TIWEdit - sample with pattern and regional settings - Alexandre Machado - 04-28-2022

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


RE: TIWEdit - sample with pattern and regional settings - PaulWeem - 04-28-2022

(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