AWinter
AWinter

Reputation: 11

Format TextItem in SmartGWT 5.0 to show its numeric value in thousands

I have a DynamicForm with several TextItems that contain numeric values (euros). It's required to add a checkbox that should switch the view mode of TextItems from euros to thousands of euros and back (let's call it "Show in thousands" checkbox). But there is also a Submit button that should always be enabled. If the user clicks on this button, regardless of selected view mode, the value in euros (not in thousands of euros) should be saved to the server.

For example: we have TextItem with value of 100,000,500.33 euros. Once we switched to "show in thousands" view mode, the visible value should become 100,001. But, if we click Submit button in this mode, the initial value (100,000,500.33) of the TextItem should be submitted to the server.

Moreover, "Show in thousands" checkbox should be checked by default.

I already tried to use FormItem.setEditorValueFormatter(FormItemValueFormatter formatter) but it did not really worked as expected.

Could you please help me to:

  1. find some handler (formatter) to use with TextItem to be able to switch to/from "show in thousands" mode
  2. enable "show in thousands" mode by default.

Upvotes: 0

Views: 324

Answers (1)

RAS
RAS

Reputation: 8156

  1. I think you need to handle this formatting of value by yourself only. Maybe inside checkboxItem.addChangedHandler(...). On selection / unselection of "show in thousands".
  2. checkboxItem.setValue(true); should work.

Upvotes: 1

Related Questions