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 sgkalluri
#790834
Hello everyone,

I would like to know if there is a change in any cell of a grid. I use the following javascript code for this...

$("#AnyGrid").on("change", ":input", function()
{
.... code ....
});

This seems to work for drop downs and text boxes of the grid. However, it does not work for datetime controls in the grid.

What could be the related event handler for datetime controls in a grid?

Best wishes,
SGK
User avatar
By amosbatto
#790836
If is recommended to use this code for change events in grids:
Code: Select all
function gridChangeHandler(fieldId, newVal, oldVal) {
  //if a value is changed inside the "mygrid" grid:
  if (fieldId.search(/^\[mygrid\]/) == 0) {
    //add code here
  }
}
$("form").setOnchange( gridChangeHandler );
If you need to check for changes in the datatime field in the grid:
Code: Select all
function gridChangeHandler(fieldId, newVal, oldVal) {
  //if a value is changed inside the datetime field in the "mygrid" grid:
  if (fieldId.search(/^\[mygrid\]\[\d+\]\[mydatetime\]$/) == 0) {
    //add code here
  }
}
$("form").setOnchange( gridChangeHandler );
See: http://wiki.processmaker.com/3.0/Grid_C ... s_in_grids
By sgkalluri
#791511
Thank you very much once again, Amos! The code worked.

Do you think the same code could be used in the following situation...

- The concerned grid is in a sub-form of the main form
- I would like to place the gridChangeHandler function in the main form as the code to be executed needs to change some fields in the main form "on change" of the concerned grid in the sub-form
User avatar
By amosbatto
#791550
sgkalluri wrote:- The concerned grid is in a sub-form of the main form
- I would like to place the gridChangeHandler function in the main form as the code to be executed needs to change some fields in the main form "on change" of the concerned grid in the sub-form
The form.setOnchange() doesn't work with subforms. The only workaround I know is to use code like this in the master form:
Code: Select all
$("form").change(function(event) {
  var fieldId = event.target.id;
  //the ID will be like "form[gridID][rowNumber][fieldID]"
  var val = event.target.value;
});

As you have got seen that after every single updat[…]

issue with processmaker 3.2

Hello! The solution to your question is the foll[…]

BPMN project disappeared

Hi Alex! , maybe you forgot to save your process[…]

mcrypt extension is deprecated!

Hello Ehsan! If you did not find the mcrypt ext[…]