Tcbrowse 2 colour one for each line

Postby Patrick Mast » Thu Jan 10, 2008 3:08 pm

Hey Guys,

Any idea how to do it with TWBrowse?
Tx

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby AHF » Thu Jan 10, 2008 3:33 pm

NageswaraRao,

Great job!

Thanks it works fine.

Antonio
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Postby nageswaragunupudi » Thu Jan 10, 2008 4:10 pm

With WBrowse also the standard codeblock works
Code: Select all  Expand view
oBrw:nClrPane := {||iif( OrdKeyNo() % 2 == 0, nEvenColor, nOddColor }

For non-indexed dbf, we can use recno() instead of OrdKeyNo().
Obviously for arrays it is even simpler.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby AHF » Thu Jan 10, 2008 4:29 pm

Look out with OrdKeyNo.

I had to change it because in network enviroment the application speed its a big problem. See my previous messages.

Antonio
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Postby James Bott » Thu Jan 10, 2008 4:51 pm

AHF,

I have modified my previous code sample to work without a database object. I works fine for me. If you will post your code perhaps I can tell why it wasn't working for you.

No changes to TCBrowse required.

Patrick, the portion of code for the setting the skipblock and colors will also work with TWBrowse.

Use the test code with FWH\samples\customer.dbf.

Regards,
James

Code: Select all  Expand view
// Purpose : Sample TCBrowse with alternating color rows without a database object
// Author  : James Bott
// Date    : 1/9/2008

#include "fivewin.ch"
#include "TCBrowse.ch"    // <-- Important

function main()
   local oWnd, oBrw, lClrFlag, cAlias

   use customer
   cAlias := alias()

   define window oWnd title "TCBrowse Test"

   @ 0,0 browse oBrw of oWnd update

   oBrw:cAlias := cAlias

   add column to browse oBrw data (cAlias)->first

   add column to browse oBrw data (cAlias)->last

   lClrFlag:=.f.

   oBrw:bSkip:={| nRecs | (nRecs:= (cAlias)->(dbskipper( nRecs )), lClrFlag:=if(nRecs/2 = int(nRecs/2), lClrFlag,!lClrFlag), nRecs) }

   oBrw:nClrPane := { || if(lClrFlag, rgb(255,255,235), rgb(192,208,179)) }
   oBrw:nLineStyle:=0

   oWnd:oClient:= oBrw

   activate window oWnd

return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby nageswaragunupudi » Thu Jan 10, 2008 4:52 pm

I totally agree with you. I never use them for these purposes.

In network environments never use ordkeyno or adskeyno for cosmetic jobs. Even otherwise limit use of the functions to absolute necessity.

But for browses of small tables and for local tables it is okay.

Adskeyno is even slower than ordkeyno. Also it involves round trips to the server and it is not good programming practice to increase network traffic for just cosmetic purposes or to place undue burden on the server. The difference is more pronounced when we deal with huge tables and hundreds of simultaneous users. Testing with smaller tables with a very few users will not give much problem though.

Relevant portions of ADS documentation of AdsGetKeyNum :
If the index is large, this function could take some time to complete because index keys are literally counted until the current key is reached.
If usFilterOption contains ADS_RESPECTFILTERS, the Advantage Client Engine must skip through all records referenced by keys in the index that pass the filter and/or scope and count them until the current key is reached. Thus, with large indexes where many records pass the filter and/or keys pass the scope, this function can be very slow.

That is the reason i prefer a solution from the browse class itself. Merit of this approach is that same code works without regard to the rdd or the datasource. I am trying to make similar modifications to txbrowse class.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Thu Jan 10, 2008 4:58 pm

Mr James

Your solution is a lot more elegant and works well. I agree we can drop considering any other alternative approaches.

I should have tested your approach first. Why did Mr AHF report this approach was not working for him? Working fine for me.

Thank you Mr James
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby James Bott » Thu Jan 10, 2008 5:08 pm

NageswaraRao,

Thanks for confirming that it does work. I don't know why AHF has been unable to get it working. Hopefully he will run the test code and report back.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby nageswaragunupudi » Thu Jan 10, 2008 5:35 pm

Mr James

Your code works well with tcbrowse and twbrowse.
I am having some issues with txbrowse. :cry:
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Enrico Maria Giordano » Thu Jan 10, 2008 6:20 pm

nageswaragunupudi wrote:Mr James

Your solution is a lot more elegant and works well. I agree we can drop considering any other alternative approaches.


Although James solution is nice I would much prefer the simpler code as in your previous example:

Code: Select all  Expand view
oBrw:nClrPane := { |nRow| iif( nRow % 2 == 0, rgb(255,255,235), rgb(192,208,179)) }


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby AHF » Thu Jan 10, 2008 6:52 pm

James,

Sorry to miss lead you.

Your code works well, however I have several bskip s and it's much easy to alter my own inherited TcBrowse class instead of chekcing out all bskip s.

Once more thanks to all for your help.

Antonio
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Postby Enrico Maria Giordano » Thu Jan 10, 2008 7:32 pm

James Bott wrote:
Code: Select all  Expand view
nRecs/2 = int(nRecs/2)


You can replace it with

Code: Select all  Expand view
nRecs % 2 = 0


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Jan 10, 2008 11:56 pm

AGF,

>Your code works well, however I have several bskip s and it's much easy to alter my own inherited TcBrowse class instead of chekcing out all bskip s.

OK, glad to hear it worked for you. Granted it will be easier right now to use the modified TCBrowse, but then you will have to modify each new version of FWH. If you getting monthly updates of FWH, then that will be more work.

It would be better to create a subclass of TCBrowse. Then you don't need to modify the original TCBrowse source for each new version of FWH.

Modifying the bSkips also would prevent you from having to make any changes with new versions of FWH.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby nageswaragunupudi » Fri Jan 11, 2008 3:03 am

Personally I prefer solutions without having to change FWH source code. ( Not that I never do it, but it is really a tedious work to keep making changes with every FWH upgrade ), unless Mr. Antonio likes to make a solution part of next release.

There is one issue to rely on bSkip block. It depends on the way the browse object uses the bSkip block. TWbrowse and TCBrowse behave similarly. TXBrowse behaves a bit differently.

We prefer a way which works for all browses and also does not rely on the data source.

I still feel it is better if the browse objects provide evaluation of the bClrPane block or bClrStd block with the visual row number ( or lEvenRow) as parameter. In fact that seemed to be the original intention of the author(s) of TCBrowse.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby AHF » Fri Jan 11, 2008 8:40 am

I agree.
I use already a Tcbrowse subclass.

Antonio
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 53 guests