Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By ptmi1047
#790162
Hello,

I have currency field in a grid and need to summarize it. I'm using currency mask in that field. The issue is the sum amount get wrong when input the value (screenshot attached). In Previous version of PM the currency mask worked fine.

Any suggestions to solve this issue?


Thanks.
Attachments
2017-04-06_095207.jpg
2017-04-06_095207.jpg (4.58 KiB) Viewed 995 times
By mishika
#790169
Hello,

On applying the mask to a value it considers only the value of the digits up to the first delimiter.
To resolve your problem you can do the following:
1. Instead of taking a sum function for the currency column, take a new text field which will store the calculated sum of all the rows of the grid.
2. You can create a button on click of which the sum will be calculated.
3. Write the following javascript for your Dynaform:
Code: Select all
document.getElementById("mask").onclick = maskcurr;
function deleteList(gridID) {
  var oGrid = $("#"+gridID); 
  var iRow = oGrid.getNumberRows();
  for (; iRow > 0; iRow--) {
     oGrid.deleteRow(iRow);
  }
}
$("#gridVar001").onAddRow( function(aRow, oGrid, rowNumber) {
   $("#form\\[gridVar001\\]\\["+rowNumber+"\\]\\[currency\\]").maskNumber({integer: true});
} );
function maskcurr(){
  var val, total = 0;
  var totalRows = $("#gridVar001").getNumberRows();
  for (var i = 1; i <= totalRows; i++) {
    val = ($("#gridVar001").getValue(i, 2));
	val = val.replace(/,/g, "");
    total = total + parseFloat(val);
  }
  $("#total").setValue(total);
}
deleteList("gridVar001");
Hope this helps

Best Regards
Mishika
BPMN project disappeared

Hi there, I'm new with ProcessMaker, using commu[…]

Hello, Since the web site "https://www.pmuse[…]

Same issue as here.. there was no problem on the l[…]

Hello, Since a while, the link "https://www.[…]