Author Topic: Dynamic Creation of Pushbuttons and Passing Array Values as Parameters  (Read 3892 times)

Sai Siddhartha

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 47
    • View Profile
Purpose:
Creating pushbuttons dynamically using "for loop".
Passing array values as parameters to these pushbuttons with "using" option.

Below example explains the creation of pushbuttons with for loop
And passing values of an array into these pushbuttons as parameters with "using" option.
When clicked on a pushbutton parameter assigned to that pushbutton is displayed on screen as comment.

Liquid UI Code:
//////////////////////////SAPLSMTR_NAVIGATION.E0100.sjs//////////////////////////

// Function to trim blank spaces at the end of the string
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');}

// Function to check if the string value is blank
function isBlank(jvar){
   if(typeof jvar == 'string') {
      jvar = jvar.trim();
   }
   if(typeof jvar == 'undefined') {
      jvar = '';
   }
   return(jvar == 'undefined' || jvar == undefined || jvar == null || jvar == "" || jvar == void 0);
}

del("X[IMAGE_CONTAINER]"); // deletes image on easy access screen
var notifications = ["","10000101","10000102","10000103","10000104","10000105"] // array

for(idx = 1, row = 0; idx <= 5; idx++){ // for loop for creating pushbuttons
      pushbutton([3+row,10], "Notification &V[idx]",{"size":[1,20], "process":z_display_param, "using":{"value":notifications[idx]}});
      row = row+2;
}

if(!isBlank(z_param)){ // displays only when clicked on any pushbutton created
    text([3+row,10], "Notification number is &V[z_param]",{ "size":24,"comment":true});
}

//function called when clicked on pushbutton with parameter
function z_display_param(param){
   set("V[z_param]",param.value);
   println("-------------param passed is"+z_param);
}

See attachment for screenshots and more information
« Last Edit: August 25, 2017, 10:05:42 AM by Rahul Gera »