Convert DW to... zebra!

Share this topic:



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 - and is looking like that:

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
-----------------------------------------------------------------------------------------------------------------------
Log:   08mar2012 Michael Zuskin   Initial version
**********************************************************************************************************************/
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))
   // Check if it's a field (regular or computed):
   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'") // transparent
   end if
   li_start_pos = li_tab_pos + 1
   li_tab_pos = Pos(ls_obj_list, "~t", li_start_pos)
loop

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

Link to this posting

Postby Hadad Eyal » 27 May 2015, 04:44

Hi, there is a bug that the code don't handle the last
Accurance of tab.
You should add to the code a check that the last pos return 0 you need to check if there is left another field at the end of lsobjectfield.
Thanks for sharing this code.
User avatar
Hadad Eyal
 
Posts: 2
Joined: 25 May 2015, 05:09

Link to this posting

Postby Ursego » 10 Jun 2015, 20:54

Eyal, if you have fixed the bug, can you send me your version of the code please?

Toda raba!
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Link to this posting

Postby Hadad Eyal » 17 Jun 2015, 00:48

/**********************************************************************************************************************
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
-----------------------------------------------------------------------------------------------------------------------
Log: 08mar2012 Michael Zuskin Initial version
**********************************************************************************************************************/
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))
// Check if it's a field (regular or computed):
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'") // transparent
end if
li_start_pos = li_tab_pos + 1
li_tab_pos = Pos(ls_obj_list, "~t", li_start_pos)
//this is the adding code just for last occurrence
if li_tab_pos = 0 then
ls_obj_name = Mid(ls_obj_list, li_start_pos + 1,len(ls_obj_list))
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'") // transparent
end if

loop

return
User avatar
Hadad Eyal
 
Posts: 2
Joined: 25 May 2015, 05:09

Link to this posting

Postby Ursego » 29 Jul 2015, 06:54

Thanx!!!
User avatar
Ursego
Site Admin
 
Posts: 112
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


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest


Convert DW to... zebra!

Share this topic:


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





cron
free counters

eXTReMe Tracker