Convert DW to... zebra!


Link to this posting

Postby Ursego » 19 Feb 2013, 21:35

Here is a small trick how to make a multi-line DW looking similar to a data control in .NET (odd rows with withe background and even rows with light grey background) - such an appearance helps users not to be lost working with many rows of data. That function (I called it uf_set_zebra_bg even though I was working in a very serious organization!) gets one argument - the DW to be zebrified:

Code: Select all
/**********************************************************************************************************************
Acc:         public
***********************************************************************************************************************
Dscr:         Sets DW's background color so odd rows are white and even rows are light grey.
            Must be called AFTER DataObject is set.
***********************************************************************************************************************
Arg:         adw - DataWindow
***********************************************************************************************************************
Developer:   Michael Zuskin -  http://linkedin.com/in/zuskin | http://code.intfast.ca/
**********************************************************************************************************************/
int li_start_pos = 1
int li_tab_pos
string ls_obj_list
string ls_obj_name
boolean lb_is_field

if not IsValid(adw) then return
if adw.DataObject = '' then return

// Make zebra background:
adw.Object.DataWindow.Detail.Color = "1073741824~tif(Mod(GetRow(), 2) = 0, RGB(220, 220, 220), RGB(255, 255, 255))"

// Make fields transparent:
ls_obj_list = adw.Describe("DataWindow.Objects")
li_tab_pos = Pos(ls_obj_list, "~t", li_start_pos)
do while li_tab_pos > 0
   ls_obj_name = Mid(ls_obj_list, li_start_pos, (li_tab_pos - li_start_pos))
   
   // If it's a field (regular or computed), make it transparent:
   lb_is_field = (adw.Describe(ls_obj_name + ".DBName") <> "!" or adw.Describe(ls_obj_name + ".Type") = "compute")
   if lb_is_field then adw.Modify(ls_obj_name + ".Background.Mode='1'")
   
   // Prepare to the next iteration:
   li_start_pos = li_tab_pos + 1
   li_tab_pos = Pos(ls_obj_list, "~t", li_start_pos)
   
   // Process the last occurrence (which doesn't have a tab after it):
   if li_tab_pos = 0 then
      ls_obj_name = Mid(ls_obj_list, li_start_pos + 1, Len(ls_obj_list))
      
      // If it's a field (regular or computed), make it transparent:
      lb_is_field = (adw.Describe(ls_obj_name + ".DBName") <> "!" or adw.Describe(ls_obj_name + ".Type") = "compute")
      if lb_is_field then adw.Modify(ls_obj_name + ".Background.Mode='1'")
   end if
loop

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

Link to this posting

Postby Escolaris » 18 Mar 2016, 12:19

Gracias!!!
Escolaris
 
Posts: 1
Joined: 17 Mar 2016, 16:51




Ketones are a more high-octane fuel for your brain than glucose. Become a biohacker and upgrade yourself to version 2.0!



cron
Traffic Counter

eXTReMe Tracker