Number Formatting with Active Form 1.2


Hi Canvas team,

how do we format numbers in an active form with the new






Hi @mwirtz,

That should be through the accounting.js global settings in WEB-INF/pages/header.script.others.ftl.



Hi @mwirtz

Here is the link to the accounting.js site as well - may be of interest also.



Hi guys,

thank you!

Actually in this case, I am not looking for a global solution. For us it would be most convenient to have a parameter in the directive that drives the formatting.

Regarding the header.script.others.ftl file.
I removed the comments and changes the settings. It doenst apply though :frowning:
Here is my content:

// accounting.js global format
// uncomment below for the settings to take effect

accounting.settings.currency.symbol = '';
accounting.settings.currency.format = {pos:'%v', neg:'(%v)', zero:'-'};
accounting.settings.currency.precision = 2;
accounting.settings.number.precision = 2;

It’s strange, when I debug those lines in the browser they are executed without doubt. But in the activeForm it’s still displayed without decimals. This is the code from our directive:


Is this maybe a bug?




Hi Marius,

You still can use combination of ng-hide=“true”, ng-model=“yourValue” and angular expression with filter {{ yourValue | formatNumber:2 }} at least as a temporary solution.



Hi Eugene,

thanks for the help. I have tried that too.
But the tm1-ui-rpt-row-cell doesnt accept ng-model (at least for me) as a parameter.




It doesn’t work for me either. And it wouldn’t work. Because for new directive tm1-ui-rpt-row-cell rowData looks like collection of methods:

it works for old style dbr. new directive doesn’t have ng-model parameter documented…
but you can use both directives in one active form. I tested this.

      <td class="text-right">
        <tm1-ui-dbr tm1-rpt-view-model="data" ng-hide="true" tm1-rpt-row-cell="rowData.getCell('Jul')" ng-model="page.testdata[$index]"></tm1-ui-dbr>
        {{page.testdata[$index] | formatNumber:0}}


Hi Marius,

I managed it worked with tm1-ui-rpt-row-cell. Just by refering to rowData.getCell(‘Jul’).value. you even no need to use ng-hide and ng-model.

 <tr ng-repeat="rowData in data.rows track by $index" ng-if="rowData.inPage">
        <td class="text-right" >
                     {{rowData.getCell('Jul').value | formatNumber:4}}
              <!-- <tm1-ui-rpt-row-cell
                                   tm1-column-elements="Jul" >
                </tm1-ui-rpt-row-cell>  -->
          <!-- .... -->


Awesome! This is exactly what I needed. Thank you


Does anybody knows how to get data of AF in that way I proposed before but If there are two dimensions in columns.
I tried {{ rowData.getCell('first dim element','second dim element').value }} but it doesn’t work.
Need it because I need to multiply value *-1 after.


Hi @eugene,

Try it out with the following instead:

{{ rowData.getCell('first dim element,second dim element').value }} 



thanks, Paul! just forked out and got the same result :slight_smile:
but I found that everything is low case in console. but it looks it works like case insensative
i.e {{ rowData.getCell('first dim element,second dim element').value }} == {{ rowData.getCell('First dim element,Second dim element').value }}. Am I right?


Hi @eugene,

You mean:

{{ rowData.getCell('First dim element,Second dim element').value }}
{{ rowData.getCell('first dim element,second dim element').value }}

? If so, then yes. They should be both, case and space insensitive.



yes. firstly copied wrong code).

Another question - how to pass a variable to rowData.getCell( ).value method?
I mean something like that {{ rowData.getCell( “{{someVariable}},actual” ).value
or {{ rowData.getCell( someVariable + ‘,actual’ ).value }}

both methods don’t work. Is it possible to pass a variable inside?

I found I can pass only one variable {{ rowData.getCell( someVariable ).value }}. So cannot put expression inside expression…


I found a way.
/* JS /
$scope.concatIT = function(a,b){
var c = a+’,’+b;
return c;
html */
{{ rowData.getCell( concatIT(someVariable,‘Actual’) ).value }}


Hi @eugene,

Had just tried it out and the second scenario you have should work. For example:

{{rowData.getCell('0' + values.month).value}}

Just need to ensure that your variable has an initial value. Otherwise, you might see some errors in the console.



Yea, I see error in console as well. thanks for advice. works as well!


Hi @eugene,

Great! Thanks for the update!



but it looks function works faster. Anyway it doesn’t look like best practice, in most cases it should be resolved by using a different measure.:slight_smile: