uf_show_columns()

Share this topic:



Link to this posting

Postby Ursego » 01 Aug 2014, 14:47

The function shows (makes visible) passed columns and hides (makes invisible) the rest of the columns in the DW. Columns of a grid DW will be shown in the order they appear in as_columns[].

Ehample of use:

Code: Select all
gn_util.uf_show_columns(dw_dept,as_cols_to_show[])
gn_util.uf_show_columns(dw_emp, {"emp_id", "list_name", "first_name"})

The source code of the function:

Code: Select all
/**********************************************************************************************************************
Acc:   public
-----------------------------------------------------------------------------------------------------------------------
Dscr:   Shows (makes visible) passed columns and hides (makes invisible) the rest of the columns in the DW.
      Columns of a grid DW will be shown in the order they appear in as_columns[].
-----------------------------------------------------------------------------------------------------------------------
Arg:   adw - DataWindow
      as_columns[] - names of columns to show (in a grid DW, as_columns[1] will be shown 1st, as_columns[2] - 2nd etc.)
**********************************************************************************************************************/
int      li_count
int      i
string   ls_col_name
string   ls_col_idx
string   ls_rc

adw.SetRedraw(false)
adw.post SetRedraw(true)

// Step 1: hide ALL columns:
li_count = Integer(adw.Describe("DataWindow.Column.Count"))
for i = 1 to li_count
   ls_col_idx = "#"+ String(i)
   ls_col_name = Upper(adw.Describe(ls_col_idx + ".Name"))
   adw.Modify(ls_col_name + ".Visible = 0")
   adw.Modify(ls_col_name + "_t.Visible = 0")
next
   
// Step 2: show columns passed in as_columns[]:
li_count = UpperBound(as_columns[])
for i = 1 to li_count
   ls_rc = adw.Modify(as_columns[i] + ".Visible = 1")
   if ls_rc = "!" then
      f_throw(PopulateError(0, "Column '" + as_columns[i] + "' doesn't exist in " + adw.DataObject + "."))
   end if
   adw.Modify(as_columns[i] + "_t.Visible = 1") // don't check ret code - some fields could not have a "..._t" label
next

return
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Link to this posting

Postby Brown Drennen » 02 Apr 2015, 10:17

This is super cool and it works great.

However, I have a few computed columns that are not hidden by iterating through "columns".

Might be cool to update this code to also hide/unhide computed columns if possible. Haven't found the solution yet myself.

Great job on this.
User avatar
Brown Drennen
 
Posts: 1
Joined: 02 Apr 2015, 10:16


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 2 guests


uf_show_columns()

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





cron
free counters

eXTReMe Tracker