Author Topic: Using '_tabrow' on Liquid UI table to get row details  (Read 8194 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 96
    • View Profile
Using '_tabrow' on Liquid UI table to get row details
« on: February 09, 2024, 02:58:25 PM »
Purpose:
Using _tabrow on Liquid UI table with pushbutton option to retrieve the clicked row details.

For the below example, Liquid UI table is displayed on SAP Easy Access screen.
Click the pushbuttons on the UI to clear or populate the table with random data.
Click the pushbuttons in the Liquid UI table to retrieve the clicked row number and get that row Material details.

Liquid UI Code:
---------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs
---------------------------------------------------------------------------------

pushbutton([TOOLBAR],'Find Position',{'process':readCursorPosition});

function readCursorPosition(){
        // Put cursor in the table cell, to find out its position
        set('V[z_rowcol]','['+_tabrow+','+_tabcol+']');
        println('Value:' + z_rowcol);
}


//USER INTERFACE
clearscreen();
table([6,1], [30,48],{"name":"z_table", "title":"LUI Table", "rows":20, "rowselection":true});
   column("Material", {"size":18, "table":"z_table", "name":"z_print_mat", "readonly":true});
   column("Desc", {"size":18, "maxlength":40, "table":"z_table", "name":"z_print_matdesc", "readonly":true});
   column("Row #'s", {"size":4, "table":"z_table","label":"@AA@", "pushbutton":true,"fcode":"?","process":fnGetClickedRowData});
               
pushbutton([1,1],"Clear Table","?",{"process":fnClearTable,"size":[2,20]});               
pushbutton([1,22],"Fill Data Table","?",{"process":fnFillTable,"size":[2,20]});               
comment([4,1],"[Click on the LUI table row pushbuttons to get the Row number and Material number]");      
         



// FUNCTIONS
// 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 fnClearTable(){
   if(typeof z_table =='object'){
      clear_values(z_table,["z_print_mat","z_print_matdesc"],20);
      for(var idx=0;idx<20;idx++){
         z_table.selectedrows[idx] = " ";
      }
   }        
}


function fnFillTable(){
   if(typeof z_table =='object'){
      for(var idx=0;idx<20;idx++){
         z_table.z_print_mat[idx] = "12340"+idx;
         z_table.z_print_matdesc[idx] = "Test Desc_"+idx;
      }
   }        
}

function fnGetClickedRowData(){
   if(_tabrow == -1){
      message("E: No data found, please click 'Fill Data Table' first");
   } else {
      zrow = _tabrow-1;
      message("S: You clicked Row# "+_tabrow+" and Material# is "+z_table.z_print_mat[zrow]);
   }
}
« Last Edit: February 28, 2024, 08:15:00 PM by Prasanthi »