uf_show_columns() to show only certain columns in DW


Link to this posting

Postby Ursego » 01 Aug 2014, 14:47

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

Example 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
/**********************************************************************************************************************
Dscr:         Shows (makes visible) the passed columns and hides (makes invisible) the rest of the columns in the DW.
            Columns in a grid DW will be shown in the order they appear in as_columns[].
***********************************************************************************************************************
Arg:         adw - DataWindow
            as_columns[] - names of columns to show
***********************************************************************************************************************
Developer:   Michael Zuskin -  http://linkedin.com/in/zuskin | http://code.intfast.ca/
**********************************************************************************************************************/
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") // don't check ret code - the column exists for sure since it was returned by Describe()
   adw.Modify(ls_col_name + "_t.Visible = 0") // don't check ret code - existence of the "..._t" label is not guaranteed
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 '" + nvl(as_columns[i], "<NULL>") + &
                              "', passed in as_columns[" + String(i) + "], doesn't exist in " + adw.DataObject + "."))
      // f_throw(): http://code.intfast.ca/viewtopic.php?t=1
      // nvl(): http://code.intfast.ca/viewtopic.php?t=5
   end if
   adw.Modify(as_columns[i] + "_t.Visible = 1") // don't check ret code - existence of the "..._t" label is not guaranteed
next

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



IF you want to ((lose weight) OR (have unbelievable (brain function AND mental clarity))) THEN click:




cron
free counters

eXTReMe Tracker