Author Topic: Clear Liquid UI Table  (Read 4643 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 95
    • View Profile
Clear Liquid UI Table
« on: July 28, 2016, 12:26:58 PM »
Purpose:
Clear all or few of the columns of a Liquid UI table.


Liquid UI Code:

// SAPLSMTR_NAVIGATION.E0100.sjs

// Function to clear the Liquid UI table based on parameters
function clear_values(tablename, columnArray, rows){   
   for (var loop = 0; loop < rows; loop++){
      for (var col=0; col<columnArray.length; col++){   
         tablename[columnArray[col]][loop] = "";
      }
   }   
}

// Function to display Material/s on the Liquid UI table
function showMatlData(){
   // Sample Materials and Descriptions
   var matDataArr = [];
   for(i=1;i<=20;i++){
      matDataArr.push({key:'Material '+i+'',value:'Description '+i+''});
   }

   // Populating table with Material numbers
   for(i=0;i<matDataArr.length;i++){
      matl_table.z_matl[ i] = matDataArr[ i].key;
      matl_table.z_matl_desc[ i] = matDataArr[ i].value;
   }
}

// Function to only clear the Description column
function clearTableDesc(){
   if(typeof matl_table == 'object'){
      clear_values(matl_table, ["z_matl_desc"], 20);
   }   
}

// Function to clear all columns
function clearTable(){
   if(typeof matl_table == 'object'){
      clear_values(matl_table, ["z_matl","z_matl_desc"], 20);
   }   
}

// User Interface
clearscreen();
// Liquid UI table and columns
table([1,1],[20,50], {"name":"matl_table", "title":"Material Info", "rows":20});
column('Material', {"table":"matl_table", "name":"z_matl", "position":1, "size":15, "readonly":true});
column('Description', {"table":"matl_table", "name":"z_matl_desc", "position":2, "size":30, "readonly":true});
pushbutton([21,1], "@01@Retrieve Material Descriptions", {"process":showMatlData});
pushbutton([23,1], "@01@Clear Descriptions", {"process":clearTableDesc});
pushbutton([25,1], "@01@Clear Table", {"process":clearTable});


See attachments for code samples!
« Last Edit: July 29, 2016, 12:04:36 PM by Benjamin Dasari »