Grid field is dependent on master form field

Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality

Moderator: amosbatto

Forum rules
Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
as13969
Posts: 14
Joined: Tue Dec 12, 2017 8:19 am
Country: Netherlands

Grid field is dependent on master form field

Unread postby as13969 » Mon Feb 12, 2018 4:01 am

Hi PM Experts,

I don't know if this inquiry has already been raised but I have a situation that I need to show/hide a column grid based on the selected item on the master form. If type of request is [Rent] the column grid [Price per Year] must show. I'm able to do show/hide column grid if the field is part of the grid but when it is dependent on master form I have difficulty implementing it.

Thanks, in advance. :)
Attachments
Evaluation.jpg
Evaluation.jpg (60.98 KiB) Viewed 28 times

amosbatto
Posts: 5834
Joined: Mon Jun 22, 2009 10:28 am
Country: Bolivia
Location: La Paz
Contact:

Re: Grid field is dependent on master form field

Unread postby amosbatto » Thu Feb 15, 2018 12:56 am

First of all, have you read this?
http://wiki.processmaker.com/index.php/2.0/Grids#Hiding.2FShowing_a_grid_column

The JavaScript code would be something like this:

Code: Select all

function showOrHideColumn(gridName, fieldName, request) {
   var colNo = getGridField(gridName, 1, fieldName).parentNode.cellIndex;
   rows = document.getElementById(gridName).rows;
   for (i=0; i < rows.length; i ++) {
      if (request == 'Rent') {
         rows[i].cells[colNo].style.display = "";
      } else {
         rows[i].cells[colNo].style.display= "none";
      }
   }
}

//call when DynaForm loads:
showOrHideColumn('productsGrid', 'pricePerYear', getField('typeOfRequest').value); 

getField
('typeOfRequest').onchange = function() {
   showOrHideColumn('productsGrid', 'pricePerYear', getField('typeOfRequest').value);
}

Where the name of the grid is "productsGrid", the name of the grid field is "pricePerYear" and the name of the dropdown field is "typeOfRequest" and one of the values in its list of options is "Rent".
Amos B. Batto ♦ ProcessMaker Technical Documentation Writer & Forum Manager ♦ Cofounder of ILLA (http://www.illa-a.org)

as13969
Posts: 14
Joined: Tue Dec 12, 2017 8:19 am
Country: Netherlands

[SOLVED]Grid field is dependent on master form field

Unread postby as13969 » Tue Feb 20, 2018 8:32 am

Thanks a lot Amosbatto! It works. :)


Return to “Using ProcessMaker 2”

Who is online

Users browsing this forum: No registered users and 8 guests