Page 1 of 1

Convert DW to... zebra!

PostPosted: 19 Feb 2013, 21:35
by Ursego
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

Re: Convert DW to... zebra!

PostPosted: 27 May 2015, 04:44
by Hadad Eyal
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.

Re: Convert DW to... zebra!

PostPosted: 10 Jun 2015, 20:54
by Ursego
Eyal, if you have fixed the bug, can you send me your version of the code please?

Toda raba!

Re: Convert DW to... zebra! bug fix...

PostPosted: 17 Jun 2015, 00:48
by Hadad Eyal
/**********************************************************************************************************************
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

Re: Convert DW to... zebra!

PostPosted: 29 Jul 2015, 06:54
by Ursego
Thanx!!!

Re: Convert DW to... zebra!

PostPosted: 18 Mar 2016, 12:19
by Escolaris
Gracias!!!