Discussion about developing the ProcessMaker application and suggestions for improving it

Moderator: ArturoRobles

By kleung

Grateful if I can receive some help.

I have a dynaform which consists of 4 different grids and some other fields. Onchange of different cells in different grids would lead to different computations in the grids / form.

My problems is how can I know which cell (rowNo, colNo) in which grid is changed and the new value as well.
The method $("#form\\[gridId\\]\\[rowNumber\\]\\[fieldId\\]").change( function() { //event handler code } ); in https://wiki.processmaker.com/3.0/Grid_Control#Change_events_in_grids handle one column at a time. But in my case, I need to monitor the changes of 2-3 columns in each grid. This method is very clumsy. Any simpler method?

I'm using PM 3.2 community version.

Thousand Thanks.

User avatar
By kirkwg

This is common usage to check or monitor fields get changed by form.setOnchange(), examples see the doc
similar to grid fields as well..
one e.g. in the link:
Code: Select all
var formId = $("form").prop("id"); //get Dynaform's ID  

//first event handler which will never executed:
$("#"+formId).setOnchange( function(fieldId, newVal, oldVal) {
   //always capitalize account name:
   if (fieldId == 'accountName') {
      $("#"+fieldId).setValue( newVal.toUpperCase() );

//This second event handler will overwrite the first event handler:
$("#"+formId).setOnchange( function(fieldId, newVal, oldVal) {
   if (fieldId == 'taxRate' || fieldId == 'price') {
      var  subtotal = parseFloat( $("#price").getValue() ) * parseFloat( $("#taxRate").getValue() );
User avatar
By kirkwg
Another example to monitor a grid field below:
var aMatches = fieldId.match(/^\[receiptGrid\]\[(\d+)\]\[receiptItem\]$/); //e.g. monitor a grid field id=receiptItem
or use var aMatches = fieldId.match(/^\[receiptGrid\]\[(\d+)\]\[(\w+)\]$/); // \w+ means monitoring any fields in this grid
aMatches[0] will return the grid_id
aMatches[1] will return the grid row happened, start from row 1, row 2, etc.
aMatches[2] will return the field_id of the grid
Code: Select all
//========== JS disable validation on a particular field inside a grid on a particular row
$( "#" + $("form").prop("id") ).setOnchange( function( fieldId, newValue, oldValue ) {
   var aMatches = fieldId.match(/^\[receiptGrid\]\[(\d+)\]\[receiptItem\]$/);
   if (aMatches) {    
     var rowNo       = aMatches[1];
     var gridFieldId = aMatches[2];
     var gridId         = "receiptGrid";
     var checkedVal = "stock";
     if (newValue === checkedVal) {     	
     } else 

Hi, I tested with the latest version of the commun[…]

Can anyone solve my problem please? :roll: :roll:

hi. i have two grid and that is fix in 31 rows i […]

:D :D tanks a lot, it is working