Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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;
});

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[…]