Article

How to hide a grid column?

Information

 
Article Number000088093
EnvironmentProduct: Rollbase
Version: 4.x, 5.x
Question/Problem Description
I am using a grid and need to use mainlookup/linklookup based on a header field.  To be able to accomplish it, it is necessary to add the field at the row grid level.
How to automatically set up the field with a value from the header and hide the column to avoid the user selecting a different field value?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution
  1. Automatically file out the field and remove header and field from the page:
Add a script component to the New page and use the code snippet below.
<script>  
  //remove the column header
  rbf_addOnLoadMethod(function(){  
    $("table[role='grid'] th[title='Client']").remove();  
  });

  function addRecord(rowIndex) {   
  var client=rbf_getFieldValue('R383572476');  //field value from the header  
    rbf_setGridValue2(0, 'R383572563', rowIndex, client);    //set the row field value
    hideCol(rowIndex);
  }

  function hideCol(rowIndex){  
    $("#rbi_grid_0_"+rowIndex+"_R383572563").hide();  //hide the row column
  }    
</script>
  1. Add addRecord(@@); on "onCreate" event handler in the grid configuration (New Page).
  2. When editing records:
Add a script component to the Edit page and use the code snippet below.
<script> 
rbf_addOnLoadMethod(function(){ 
   $("table[role='grid'] th[title='Client']").remove(); 

   var n = rbf_getMaxRowIndex2(0);
   for (var rowIndex=0; rowIndex<n; rowIndex++) {
      hideCol(rowIndex); 
   } 
}); 

function addRecord(rowIndex) { 
   rbf_setGridValue2(0, 'R383572563', rowIndex, '{!R383572476#id}'); 
   hideCol(rowIndex);
} 

function hideCol(rowIndex){
   $("#rbi_grid_0_"+rowIndex+"_R383572563").hide(); 
} 

</script>
  1. Add addRecord(@@); on "onCreate" event handler in the grid configuration (Edit Page).
PS: Replace the current relationship and header name accordingly.
Workaround
Notes
Attached XML Demo APP.
Last Modified Date3/26/2018 5:53 PM


Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025