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
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
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:
User avatar
By amosbatto
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);

Thanks for your reply, Press F12 in your web bro[…]

I created a new process to make it easier to look […]

Genial!!! gracias. :D

This is resolved. I took a punt on Amos' suggesti[…]