|
Class TNumberFormat
To format numbers in locale sensitive manner use
<com:TNumberFormat Pattern="0.##" value="2.0" />
Numbers can be formatted as currency, percentage, decimal or scientific
numbers by specifying the Type attribute. The known types are "currency",
"percentage", "decimal" and "scientific".
If someone from US want to see sales figures from a store in Germany (say
using the EURO currency), formatted using the german currency, you would need to
use the attribute Culture="de_DE" to get the currency right, e.g. 100,00. The
decimal and grouping separator is then also from the de_DE locale. This may lead
to some confusion because people from US know the "," as thousand separator.
Therefore a "Currency" attribute is available, so that the output from the
following example results in 100.00.
<com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" />
Namespace: System.I18N
Properties
- Value, number,
Gets or sets the number to format. The tag content is used as Value if the Value
property is not specified.
- Type, string,
Gets or sets the formatting type. The valid types are 'decimal', 'currency',
'percentage' and 'scientific'.
- Currency, string,
Gets or sets the currency symbol for the currency format. The default is 'USD'
if the Currency property is not specified.
- Pattern, string,
Gets or sets the custom number formatting pattern.
- DefaultText, string,
Gets or sets the default text. If Value is not set, DefaultText will be shown
instead of the default currency Value/Pattern.
-
TComponent
-
TApplicationComponent
-
TControl
implements
IRenderable,
IBindable
-
TI18NControl
-
TNumberFormat
implements
IDataRenderer
Package: System\ I18N
Copyright:
Copyright © 2005-2014 PradoSoft
License:
http://www.pradosoft.com/license/
Author:
Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
Version:
v1.0, last update on Sat Dec 11 17:49:56 EST 2004
Located at I18N/TNumberFormat.php
Methods summary
public
string
|
#
getPattern( )
Get the number formatting pattern.
Get the number formatting pattern.
Returns
string format pattern.
|
public
|
#
setPattern( string $pattern )
Set the number format pattern.
Set the number format pattern.
Parameters
- $pattern
string format pattern.
|
public
string
|
#
getValue( )
Get the numberic value for this control.
Get the numberic value for this control.
Returns
string number
|
public
|
#
setValue( string $value )
Set the numberic value for this control.
Set the numberic value for this control.
Parameters
- $value
string the number value
|
public
string
|
#
getDefaultText( )
Get the default text value for this control.
Get the default text value for this control.
Returns
string default text value
|
public
|
#
setDefaultText( string $value )
Set the default text value for this control.
Set the default text value for this control.
Parameters
- $value
string default text value
|
public
string
|
|
public
|
#
setData( string $value )
Set the numberic value for this control. This method is required by IDataRenderer . It is the same as TNumberFormat::setValue() .
Parameters
- $value
string the number value
Since
3.1.2
See
Implementation of
|
public
string
|
#
getType( )
Get the formatting type for this control.
Get the formatting type for this control.
Returns
string formatting type.
|
public
|
#
setType( string $type )
Set the formatting type for this control.
Set the formatting type for this control.
Parameters
- $type
string formatting type, either "decimal", "currency","percentage" or "scientific"
Throws
TPropertyTypeInvalidException
|
public
string
|
#
getCurrency( )
Returns
string 3 letter currency code. Defaults to 'USD'.
|
public
|
#
setCurrency( string $currency )
Set the 3-letter ISO 4217 code. For example, the code "USD" represents the US
Dollar and "EUR" represents the Euro currency.
Set the 3-letter ISO 4217 code. For example, the code "USD" represents the US
Dollar and "EUR" represents the Euro currency.
Parameters
- $currency
string currency code.
|
protected
string
|
#
getFormattedValue( )
Formats the localized number, be it currency or decimal, or percentage. If
the culture is not specified, the default application culture will be used.
Formats the localized number, be it currency or decimal, or percentage. If
the culture is not specified, the default application culture will be used.
Returns
string formatted number
|
public
|
#
render( THtmlWriter $writer )
Renders the control. This method is invoked by TControl::renderControl() when the
control is visible. You can override this method to provide customized rendering
of the control. By default, the control simply renders all its child
contents.
Renders the control. This method is invoked by TControl::renderControl() when the
control is visible. You can override this method to provide customized rendering
of the control. By default, the control simply renders all its child
contents.
Parameters
- $writer
THtmlWriter
the writer used for the rendering purpose
Overrides
|
Methods inherited from TControl
__construct(),
__get(),
addParsedObject(),
addToPostDataLoader(),
addedControl(),
applyStyleSheetSkin(),
autoBindProperty(),
autoDataBindProperties(),
bindProperty(),
broadcastEvent(),
bubbleEvent(),
clearChildState(),
clearControlState(),
clearNamingContainer(),
clearViewState(),
convertUniqueIdToClientId(),
createChildControls(),
createControlCollection(),
dataBind(),
dataBindChildren(),
dataBindProperties(),
ensureChildControls(),
findControl(),
findControlsByID(),
findControlsByType(),
focus(),
getAdapter(),
getAllowChildControls(),
getAttribute(),
getAttributes(),
getChildControlsCreated(),
getClientID(),
getControlStage(),
getControlState(),
getControls(),
getCustomData(),
getEnableTheming(),
getEnableViewState(),
getEnabled(),
getHasAdapter(),
getHasAttributes(),
getHasChildInitialized(),
getHasControls(),
getHasInitialized(),
getHasLoaded(),
getHasLoadedPostData(),
getHasPreRendered(),
getID(),
getIsSkinApplied(),
getNamingContainer(),
getPage(),
getParent(),
getRegisteredObject(),
getSkinID(),
getSourceTemplateControl(),
getTemplateControl(),
getUniqueID(),
getViewState(),
getVisible(),
hasAttribute(),
initRecursive(),
isDescendentOf(),
isObjectRegistered(),
loadRecursive(),
loadState(),
loadStateRecursive(),
onDataBinding(),
onInit(),
onLoad(),
onPreRender(),
onUnload(),
preRenderRecursive(),
raiseBubbleEvent(),
registerObject(),
removeAttribute(),
removedControl(),
renderChildren(),
renderControl(),
saveState(),
saveStateRecursive(),
setAdapter(),
setAttribute(),
setChildControlsCreated(),
setControlStage(),
setControlState(),
setCustomData(),
setEnableTheming(),
setEnableViewState(),
setEnabled(),
setID(),
setPage(),
setSkinID(),
setTemplateControl(),
setViewState(),
setVisible(),
trackViewState(),
traverseChildControls(),
unbindProperty(),
unloadRecursive(),
unregisterObject()
|
Methods inherited from TComponent
__call(),
__destruct(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
Constants inherited from TControl
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID
|
Properties summary
protected static
NumberFormat
|
$formatter |
|
#
Default NumberFormat, set to the application culture.
Default NumberFormat, set to the application culture.
|
|