Author Topic: Read LiquidUI Table  (Read 4778 times)

lakshmi.k

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 7
    • View Profile
Read LiquidUI Table
« on: February 29, 2024, 08:33:15 PM »
Purpose:
Read values in the LiquidUI table with toolbar pushbutton.

Below example demonstrates read LiquidUI table data and display them on the console window.

Liquid UI Code:
------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
------------------------------------------------------------------------------------------------------------------------------------
//Delete image container
del("X[IMAGE_CONTAINER]");

//User Interface
table([1,5],[10,45],{"name":"va01_AllItems","title":"All items", "rows":10, "rowselection":true,"columnselection":true});
column('Item',{"table":"va01_AllItems","size":4,"name":"z_va01_item","position":1});
column('Material',{"table":"va01_AllItems","size":15,"name":"z_va01_material","position":2});
column('Order Quantity',{"table":"va01_AllItems","size":15,"name":"z_va01_Orderquantity","position":3});

pushbutton([TOOLBAR],"Read LiquidUI Table","?",{"process":readLiquidUITableValues,"size":[2,23]});

//Functions
// Function prototype to trim blank characters from a string
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

// Function to return trimmed string
function getString(strInput) {
   return (typeof(strInput) == 'undefined' || strInput == 'undefined') ? "" : strInput.toString().trim();
}

// Function to check for blank string
// Specifically used to determine if input exist in the edit field
function isBlank(strInput) {
   var strVal = getString(strInput);
   var blank = strVal == "";
   return blank;
}


//function to read LiquidUI table 'All items'
function readLiquidUITableValues(){
   i = 0;
   //declaring variables and arrays
   temp_items=[];
   temp_material=[];
   temp_quantity=[];
   
   STARTLABEL:; 
   z_temp1 = va01_AllItems.z_va01_item[i ];   
   z_temp2 = va01_AllItems.z_va01_material[i ];   
   z_temp3 = va01_AllItems.z_va01_Orderquantity[i ];
   
   if(!isBlank(z_temp1) && !isBlank(z_temp2) && !isBlank(z_temp3)){   

      temp_items.push(z_temp1);
      temp_material.push(z_temp2);
      temp_quantity.push(z_temp3);
   
      i=i+1;
      goto STARTLABEL;
      
   }   
    
   println('-----------items-------'+temp_items);
   println('-----------material-------'+temp_material);
   println('-----------order quantity-------'+temp_quantity);
   

}