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 HeshanKaru1994
#824578
Hi,
How to load value from pmt table to grid dropdown associated with a particular id and if we add a new row to the grid all the dropdown values should be generated as well.

Thank you
User avatar
By amosbatto
#824595
If you have a grid which contains the following fields:
- text field with ID "code",
- dropdown with the ID "selectName"

Then in your "selectName" dropdown, use the following SQL:
SELECT NAME, NAME FROM PMT_MY_TABLE WHERE [email protected]@code
User avatar
By amosbatto
#824616
In a trigger fired after the Dynaform, you can use code like this:
Code: Select all
if (!empty(@=myGrid)) {
   for ($i =1; $i < count(@=myGrid); $i++) {
      //if no option selected in "myDropdown"  field in grid for row number $i:
      if (@=myGrid[$i]['myDropdown'] == '') {
          //not sure what you want to do here. Am setting to the value:
          @=myGrid[$i]['myDropdown'] = 'some value';
          //if wanting to throw an exception:
          //throw new Exception("Error: The dropdown value in row $i can't be empty!");
          //if wanting to display a message to user:
         //$g = new G();
         //$g->SendMessageText("Error: The dropdown value in row $i can't be empty!", "ERROR");
      }
   }
}
If wanting to do it in JavaScript:
Code: Select all
var dropdownColNo = 3; //set to column number of dropdown in grid; Counting starts from 0

var formId = $("form").prop(" id");
$("#" +formId).setOnSubmit( function() {
    aGridVals = $("#myGrid").getValue();

    for(var rowNo  in aGridVals) {
        if (aGridVals[rowNo][dropdownColNo] == '') {
             alert("Dropdown in row "+(rowNo+1)+" is empty!);
             //if wanting to set to a default value:
             //add 1 because counting columns and rows starts from 1, not 0.
             $("#myGrid").setValue("default value" , rowNo+1, dropdownColNo+1);
        }
    }  
});
Pasar desde una PM table a Grid

Muchas gracias Amos, lo reviso y te cuento como me[…]

Loading issue

I spun up a test upgrade VM with a restored backup[…]

We are professionals and experts in what we do, fo[…]

Custom Header on Dynaforms

Thanks for the reply. What I ended up doing, sinc[…]