1. Script for hiding a column

    Article: AN0001911Updated:

    Hiding or displaying column is defined primarily in column detail or in  setup of Multiple columns, if the class uses them. However, sometimes we need to hide the column based on other facts, which we find out only at the runtime. We can always hide column by a script but we cannot display column by the script if it was hidden directly in the column definition or if the columns are not selected in the Multiple columns settings.

    Hiding column in the list of records

    Following script will hide the column with code column_code in the list of records.
    Where to use this script: Class detail: Script for record detailfunction OnLoad()
    {
      OGColumns['column_code'].Visible = false;
    }

    Hiding column in the record detail

    Following script will hide the column 'segmentation'.
    Where to use this script: Class detail: Script for list of records

    function OnAfterLoadColumns()
    {
     OGColumns['segmentation'].Visible = false;
    }


    Following script will hide the column 'name' in a class with multiple columns for a newly created record if there is reference in column 'category_request' to a record of another class, that has in column 'code' value 'HR requests'. Because we want to supress behaviour defined in multiple columns, the script  has to run only after setting up columns according to the definition in Multiple columns. Therefore, we run the script in the event OnPreRender.

    function OnPreRender()
    {
      var visible = true;
      var name = OGColumns['name'];
      var rcId = OGColumns['request_category'].ColumnUI.GetData();
      if ( rcId != null && name.Visible)
      {
        var clRC = OGModel.ClassDefs['request_category'];
        var drRC = OG.DataRow.GetDataById( clRC.Id, rcId);
        if ( drRC != null && drRC['code'] == 'HR requests')
        {
          visible = false;
        }
      }
      name.Visible = visible;
    }

×