3.0 beta 2

Formating string

Is there a list for the formating strings(display mask) on this site? There are examples of how to do a date format, but what about text formating and number formating? Thnx.
Wai
January 31,
The String format returns the text as is (no formatting).

The number format allows to specify the number of decimals and optionally the thousands separator - #,###.##

/aw.formats.number/settextformat.html
Alex (ActiveWidgets)
January 31,
With the following code. I was expecting '$ 29.01' to be displayed, but I am getting a blank input field. Anything I did wrong.


<html>
<script src="./ActiveWidgets/runtime/lib/aw.js"></script>
<link href="./ActiveWidgets/runtime/styles/system/aw.css" rel="stylesheet"></link>
<body>
Enter the Number :
<script>
var num = new AW.Formats.Number;
num.setTextFormat("$ #,###.##");

var obj = new AW.UI.Input;
obj.setControlFormat(num);
obj.setControlValue("29.01");
document.write(obj);

obj.onControlValidated = function(){
alert(this.getControlValue());
};
</script>
</body>
</html>

Wai
January 31,
Normally the input box work the other way round - from text to value. However you can force it to convert both ways -

var num = new AW.Formats.Number;
num.setTextFormat("$ #,###.##");

var obj = new AW.UI.Input;
obj.setControlFormat(num);
obj.setControlValue(29.01);
obj.setControlText(function(){
    var value = this.getControlValue();
    var format = this.getControlFormat();
    return format.valueToText(value);
});
document.write(obj);

obj.onControlValidated = function(text){
    var format = this.getControlFormat();
    var value = format.textToValue(text);
    var final = format.valueToText(value);
    this.setControlValue(value);
    this.setControlText(final);
};
Alex (ActiveWidgets)
January 31,
Thank you Alex. I thought that your tool library made it work both ways just like other libraries I have used in the past for Windows development.
Wai
January 31,
Alex,

One more help. I am not able to change the text-align style property of a input box by doing a obj.setStyle("text-align", "right"). However, labels and check boxes are OK. Is this specific to the AW-UI-Input?
Wai
February 1,
This is a problem with IE implementation of the <input> element - it does not inherit the style settings of the parent. You have to set the style directly on the input box -

obj.getContent("box/text").setStyle("text-align", "right");
Alex (ActiveWidgets)
February 4,
Thnx again, you are great help.
Wai
February 4,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.