Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#23033
Here is some code to do those things:
Code: Select all
var dynaformOnload = function() {
   //set value for the first row:
   getGridField("MyGrid", 1, "MyField").value = getField("someField").value;

  //set value for all subsequent rows that are added dynamically:
  grid_MyGrid.onaddrow = function(iRow) {
      getGridField("MyGrid", iRow, "MyField").value = getField("someField").value;
  }

  //replace  sum sign:
  var nCol = 2; //set to the index of the column which has the sum sign
  var gridName = "mygrid"; //set to the name of the grid
  var nLastRow = document.getElementById(gridName).rows.length - 1;
  document.getElementById(gridName).rows[nLastRow].cells[nCol].innerHTML =
     document.getElementById(gridName).rows[nLastRow].cells[nCol].innerHTML.replace('Σ', 'Sum');
}
see:
http://wiki.processmaker.com/index.php/ ... ding_a_Row

Edited to change "var dynaformOnload = function()" to "var dynaformOnload = function() {"
#23113
Oh, I see an error in my code. Change "var dynaformOnload = function()" to "var dynaformOnload = function() {"

That should force the code to execute only after the dynaform has finished loading. The other problem could be that you misspelled the name of your grid or the name of the field. Remember that it is case sensitive. Also remember to use the name of the grid obect, which is embedded in the master form. Do not use the name of the grid form. If you don't know what I mean, post the XML for your form and I can tell you the correct name of the field to use in the function.
#23151
It worked but I also wanted to display the value of the "Sum" to a text box. How do I do that assuming that I added a text box named "Total". All the text box does is to display the total amount that was calculated from the Sum in the grid and when there are some changes, it should update based on the amount that the Sum is holding.
#23153
<name type="text" maxlength="64" validate="Any" required="0" readonly="1" size="15" mode="view" btn_cancel="Cancel" mask="" strto="" dependentfields="" defaultvalue="" hint="" formula="" function="" sqlconnection="" savelabel="0">
<en>Name</en>
</name>
<Date type="text" maxlength="64" validate="Any" required="0" readonly="0" size="15" mode="view" btn_cancel="Cancel" mask="" strto="" dependentfields="" defaultvalue="" hint="" formula="" function="" sqlconnection="" savelabel="0">
<en>Date</en>
</Date>
<JobNumber1 type="text" maxlength="64" validate="Any" required="0" readonly="0" size="15" mode="edit" btn_cancel="Cancel" mask="" strto="" dependentfields="" defaultvalue="" hint="" formula="" function="" sqlconnection="" savelabel="0">
<en>JobNumber</en>
</JobNumber1>
<AddTest type="text" maxlength="64" validate="Real" required="0" readonly="1" size="15" mode="edit" btn_cancel="Cancel" mask="" strto="" dependentfields="" defaultvalue="0" hint="" formula="" function="" sqlconnection="" savelabel="0">
<en>Total Reimbursement</en>
</AddTest>
<Total type="javascript"><![CDATA[var dynaformOnload = function() {
total = 0;
//set value for the first row:
getGridField("TestGridd", 1, "Value2").value = getField("AddTest").value;

//set value for all subsequent rows that are added dynamically:
grid_TestGridd.onaddrow = function(iRow) {
getGridField("TestGridd", iRow, "Value2").value = getField("AddTest").value;
total += parseFloat(getGridField("TestGridd", iRow, "Value2").value);
getField("AddTest").value = total;
}


//replace sum sign:
var nCol = 3; //set to the index of the column which has the sum sign
var gridName = "TestGridd"; //set to the name of the grid
var nLastRow = document.getElementById(gridName).rows.length - 1;
document.getElementById(gridName).rows[nLastRow].cells[nCol].innerHTML =
document.getElementById(gridName).rows[nLastRow].cells[nCol].innerHTML.replace('Σ', 'Total Reimbursement');
}]]></Total>
<TestGridd type="grid" xmlgrid="4354301434fce06ffd24bf6025751946/6719645254fd227950bce60003405414" addrow="1" deleterow="1" btn_cancel="Cancel"/>
<CurUser type="hidden" mode="edit" btn_cancel="Cancel"> </CurUser>
<CurNum type="hidden" mode="edit" btn_cancel="Cancel"> </CurNum>
<Add type="button" onclick="" btn_cancel="Cancel" required="0" readonly="0" savelabel="0">
<en>Add New</en>
</Add>
<Save type="button" btn_cancel="Cancel" onclick="Saves" required="0" readonly="0" savelabel="0">
<en>Save</en>
</Save>
<Saves type="javascript"><![CDATA[function saveIt() {
var url = location.href.substring(0, location.href.lastIndexOf('/')) + "main" + "/caseListExtJS";
saveAndRedirectForm("", url);
//window.location.href = "https://192.168.0.192/sysworkflow/en/cl ... eListExtJS";
}
getField("Save").onclick = saveIt;]]></Saves>
<___pm_boot_strap___ type="javascript" meta="s8jd"><![CDATA[/* @! Autogenerated by Processmaker weboot; Do not modify this content, this is autogenerated alway when dynaform is updated */ hideRowById('Add'); ]]></___pm_boot_strap___>

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]