@qooxdoo/framework
Version:
The JS Framework for Coders
88 lines (71 loc) • 2.31 kB
JavaScript
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2007 OpenHex SPRL, http://www.openhex.org
License:
MIT: https://opensource.org/licenses/MIT
See the LICENSE file in the project's top-level directory for details.
Authors:
* Gaetan de Menten (ged)
************************************************************************ */
/**
* Specific data cell renderer for numbers.
*/
qx.Class.define("qx.ui.table.cellrenderer.Number",
{
extend : qx.ui.table.cellrenderer.Conditional,
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties :
{
/**
* NumberFormat used to format data. If the numberFormat contains a
* prefix and/or postfix containing characters which needs to be escaped,
* those need to be given to the numberFormat in their escaped form
* because no escaping happens at the cellrenderer level.
*/
numberFormat :
{
check : "qx.util.format.NumberFormat",
init : null,
nullable : true
}
},
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members :
{
_getContentHtml : function(cellInfo)
{
var nf = this.getNumberFormat();
if (nf)
{
if (cellInfo.value || cellInfo.value == 0) {
// I don't think we need to escape the resulting string, as I
// don't know of any decimal or separator which use a character
// which needs escaping. It is much more plausible to have a
// prefix, postfix containing such characters but those can be
// (should be) added in their escaped form to the number format.
return nf.format(cellInfo.value);
} else {
return "";
}
}
else
{
return cellInfo.value == 0 ? "0" : (cellInfo.value || "");
}
},
// overridden
_getCellClass : function(cellInfo) {
return "qooxdoo-table-cell qooxdoo-table-cell-right";
}
}
});