# Format a label element

**URL:** https://forum.servoy.com/t/format-a-label-element/12801
**Category:** Classic Servoy
**Created:** [September 2, 2010, 5:55pm UTC](https://forum.servoy.com/t/format-a-label-element/12801 "2010-09-02T17:55:53Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![jasantana](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jasantana](https://forum.servoy.com/u/jasantana)
#### Post date: [September 2, 2010, 5:55pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/1 "2010-09-02T17:55:53Z")

</div>

How can I give a numeric format to a label element? That propery does not exist for labels

Thanks in advance

---

<div class="post-metadata">

### Author: ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)
#### Post date: [September 2, 2010, 7:55pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/2 "2010-09-02T19:55:49Z")

</div>

I suppose you want to format the value of a dataprovider?

Create a calculation, where you can format the value using utils.numberFormat() function.

---

<div class="post-metadata">

### Author: ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)
#### Post date: [September 3, 2010, 11:44am UTC](https://forum.servoy.com/t/format-a-label-element/12801/3 "2010-09-03T11:44:53Z")

</div>

It would be cool if we could apply formatting for labels like this:

```auto
%%unitprice|¤#.00%%

```

---

<div class="post-metadata">

### Author: ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)
#### Post date: [September 3, 2010, 1:37pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/4 "2010-09-03T13:37:20Z")

</div>

+1

---

<div class="post-metadata">

### Author: ![Kaptan](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@Kaptan](https://forum.servoy.com/u/Kaptan)
#### Post date: [November 25, 2010, 8:09pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/5 "2010-11-25T20:09:02Z")

</div>

+1 ![:)]( "Smile")

---

<div class="post-metadata">

### Author: ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)
#### Post date: [November 25, 2010, 9:22pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/6 "2010-11-25T21:22:54Z")

</div>

+1

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [November 25, 2010, 10:01pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/7 "2010-11-25T22:01:02Z")

</div>

+1

---

<div class="post-metadata">

### Author: ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)
#### Post date: [November 26, 2010, 9:49am UTC](https://forum.servoy.com/t/format-a-label-element/12801/8 "2010-11-26T09:49:50Z")

</div>

Agree, but it would be nice if this is also possible when creating a label with tags.

%%…%%

and that you can format this also (using a designtime property, or somehow in the %%…%%)

---

<div class="post-metadata">

### Author: ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)
#### Post date: [July 29, 2011, 10:13pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/9 "2011-07-29T22:13:33Z")

</div>

Did formatting of labels make it into Servoy 6?

I recall speaking with Paul Bakker at Servoy World about this and was told it would be included in Servoy 6. I also saw the feature request in text form somewhere (forum, support, e-mail, etc), but I cannot locate it. In Servoy 6, I was expecting to see a ‘format’ property when selecting a label (similar to the field format property), but it’s not there.Perhaps, label formatting made it into Servoy 6 but is implemented differently from what I was expecting. Does anyone know about this?

---

<div class="post-metadata">

### Author: ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)
#### Post date: [August 1, 2011, 8:27am UTC](https://forum.servoy.com/t/format-a-label-element/12801/10 "2011-08-01T08:27:39Z")

</div>

Hi Kim,

I think you must have misinterpreted what I said, because formatting on labels has never bee on the roadmap for Servoy 6.0.

Label formatting is scheduled for the next version of Servoy though, based on feedback from yourself and others at ServoyWorld '11.

Paul

---

<div class="post-metadata">

### Author: ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)
#### Post date: [August 1, 2011, 6:10pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/11 "2011-08-01T18:10:57Z")

</div>

Hi, Paul.

Please let us know when it gets implemeneted.

---

<div class="post-metadata">

### Author: ![hsummerhays](https://avatars.discourse-cdn.com/v4/letter/h/df788c/32.png) [@hsummerhays](https://forum.servoy.com/u/hsummerhays)
#### Post date: [September 12, 2011, 9:38pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/12 "2011-09-12T21:38:20Z")

</div>

I am using form variables as my dataprovider and setting them in the onrender event using something like…

```auto
_myFormVar = utils.numberFormat(foundset.myField, "$####,###,###,##0")

```

---

<div class="post-metadata">

### Author: ![hsummerhays](https://avatars.discourse-cdn.com/v4/letter/h/df788c/32.png) [@hsummerhays](https://forum.servoy.com/u/hsummerhays)
#### Post date: [September 13, 2011, 10:05pm UTC](https://forum.servoy.com/t/format-a-label-element/12801/13 "2011-09-13T22:05:54Z")

</div>

No workaround is ever as simple as you’d like it to be. Anyway, here is the code I ended up using in my project. I hope it is helpful to someone. This code eliminates the need for me to create calculations, but still allows me to use a button and show a hand icon and display formatted data. By the way, all of my form variables start with an underscore and are named somewhat like the table field (e.g. field: daytotal, formvar: \_day).

```auto
function onRender(event)
{
    // TODO: Put format in button object if that property is added.
    // Using buttons to show data - format before showing.
    /** @type {JSRecord<db:/statistics/daymonthstats>} */ 
    var record = event.getRecord();
    var element = event.getRenderable();
    var providerId = element.getDataProviderID();
    if (record.stattype && providerId && providerId.match(/^_/) && providerId !== "_statTypeLabel")
    {
        var format = (record.stattype.match(/dollar/i) ? "$" : "") + "####,###,###,##0";
        var name = providerId.substr(1).toLowerCase() + "total";
        var form = forms[controller.getName()];
        form[providerId] = utils.numberFormat(record[name], format);
    }
}

```
