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

Moderator: ArturoRobles

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.
#829412
i want Fix the grid to 31 rows and add the second columns
with this code but it not work :?: and i do not know why??? plz help
for (i=0; i < 30; i++) {
$("#gridVar001").addRow();
$("#gridVar002").addRow();
}

$("#60812377960ff8494201cb7011756346").mouseover(function(){

var row1= $("#gridVar001").getNumberRows();
var col_grid1 = 0;
var total_grid1 = 0;

var row2= $("#gridVar002").getNumberRows();
var col_grid2 = 0;
var total_grid2 = 0;

var total = 0;

for(var i=1;i<=row1;i++){

col_grid1 = parseInt($("#gridVar001").getValue(i,5));
total_grid1 += col_grid1;

}


for(var j=1;j<=row2;j++){

col_grid2 = parseInt($("#gridVar002").getValue(j,5));
total_grid2 += col_grid2;

}


total = total_grid1 + total_grid2;


$("#sum").setValue(total);
});
#829413
Hi there,

1/ First you can't use mouseover function, see link for form's functions supported:
https://wiki.processmaker.com/3.0/JavaScript_Functions_and_Methods#form.setOnchange

Use $("#60812377960ff8494201cb7011756346").setOnchange(function (field, newValue, oldValue){
// calculate your total here...
});

2/ make use the property of 'function', say at Grid 1 & Grid 2's column 2,
https://wiki.processmaker.com/3.1/JavaScript_Functions_and_Methods#grid.getSummary
https://wiki.processmaker.com/3.0/Grid_Control#Function
Dynaform > properties > function > select SUM (for grid column 2)

it will provide you a column summation, so you don't need to have a FOR loop to calculate by yourself.
Example codes are in below FYI:
Code: Select all
for (var i=0; i < 30; i++) {
    $("#gridVar001").addRow();
    $("#gridVar002").addRow();
}

$("#60812377960ff8494201cb7011756346").setOnchange(function(field, newValue, oldValue){
      //something like..
     var total_grid1 = parseFloat($("#gridVar001").getSummary("column2_id"));
     var total_grid2 = parseFloat($("#gridVar002").getSummary("column2_id"));
      var total = total_grid1 + total_grid2;

      $("#sum").setValue(total);
});
pmusers.com

Hi, pmusers.com is a good resource when it comes t[…]

How to "un-stuck" a case

Thanks a lot. The example here is my solution for […]

Hello everyone, sometimes I have the following Pr[…]

Language toggle on the Dynaform

The Language option is at the top of the Dynaform […]