TXBrowse Bug

TXBrowse Bug

Postby James Bott » Mon Jan 07, 2008 12:02 am

After you change the width of a TXBrowse column (by dragging with the mouse) when the currently highlighted row gets redisplayed, it displays the wrong record.

Using FW 8.10/xHarbour

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

Postby nageswaragunupudi » Mon Jan 07, 2008 2:33 am

I do not experience this problem
Regards

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

Postby James Bott » Mon Jan 07, 2008 2:55 am

Apparently it only happens when using a database object.

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

Postby nageswaragunupudi » Mon Jan 07, 2008 5:32 am

Mr James

I have tested with TDataBase class of FWH. It works fine for me. I am not getting the problem you mentioned.

I would suggest you to revisit the navigation codeblocks assigned by you and in particular the bSkip block.
Regards

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

Postby James Bott » Mon Jan 07, 2008 5:43 am

NageswaraRao,

I have the problem using TDatabase. Below is my code.

Highlight a record in the middle, then resize one of the columns. The next record (off the bottom) is the one that is displayed when the highlighted record gets refreshed after the resizing.

James


Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function main()
   local oWnd,oBrw,oCust,oCol

   use customer
   database oCust

   define window oWnd

   oBrw := TXBrowse():New( oWnd )

   oCol := oBrw:AddCol()
   oCol:cHeader       := "First"
   oCol:bStrData      := { || oCust:first }

   oCol := oBrw:AddCol()
   oCol:cHeader       := "Last"
   oCol:bStrData      := { || oCust:last }

   oBrw:CreateFromCode()

   oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW

   oBrw:bSkip:= {| nRecs | oCust:skipper( nRecs ) }

   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 » Mon Jan 07, 2008 5:52 am

Mr James,

Will you please try with the following codeblock assignments ?
Code: Select all  Expand view
oBrw:bGoTop    := {|| oCust:GoTop() }
oBrw:bGoBottom := {|| oCust:GoBottom()  }
oBrw:bSkip     := {| n | oCust:Skipper( iif( n == nil,1,n) )}, ;
oBrw:bBof      := {|| oCust:Bof() }
oBrw:bEof      := {|| oCust:Eof() }
oBrw:bBookMark := {| n | iif( n == nil,(oCust:RecNo()),(oCust:GoTo(n)) ) }
oBrw:bKeyNo    :=oBrw:bBookMark
oBrw:bKeyCount := {|| oCust:RecCount()}

A note on bSkip. If the TData skipper defaults nRecs to 1, it is enough to write oBrw:bSkip := {| nRecs | oCust:skipper( nRecs ) }, if not please adopt the above assignment.
Regards

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

Postby nageswaragunupudi » Mon Jan 07, 2008 5:54 am

I have added a new method SetODbf with the above assignments in my personal extended version of xBrowse. You can also include the assignments in your TData class.
Regards

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

Postby James Bott » Mon Jan 07, 2008 6:10 am

NageswaraRao,

I find that this line solves the problem. None of the others you provided are actually needed.

oBrw:bBookMark := {| n | iif( n == nil,(oCust:RecNo()),(oCust:GoTo(n)) ) }

I have not used TXBrowse before and none of the other browses I have used have a bBookMark codeblock so I am not familiar with it. However, it does appear that the default bBookmark should have worked.

Code: Select all  Expand view
::bBookMark := {| n | iif( n == nil,;
                                     ( cAlias )->( RecNo() ),;
                                     ( cAlias )->( DbGoto( n );
                                    ) ) }


I do agree that it would be nice to have a setoDBF() method in TXBrowse.

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

Postby James Bott » Mon Jan 07, 2008 6:21 am

Ok, I found the problem. TDatabase:goto() reloads the buffer after the dbgoto() call. When I change the line to this it works:

oBrw:bBookMark := {| n | iif( n == nil,;
( oCust:cAlias )->( RecNo() ),;
( oCust:cAlias )->( DbGoto( n ), oCust:load();
) ) }

Thus the two codeblocks that must be assigned are bSkip and bBookMark.

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

Postby nageswaragunupudi » Mon Jan 07, 2008 6:23 am

Defaults assigned through SetRDD might not have worked because defaults do not let your TData class to read the data into the buffer.

SetRDD method gets executed invariably. At times this may give unexpected results if a different alias is selected when the browse is created. It is always safe to assign all the codeblocks and not allow SetRDD to assign any defaults
Regards

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

Postby nageswaragunupudi » Mon Jan 07, 2008 6:23 am

Yes thats what I expected. Our postings crossed
Regards

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

Postby nageswaragunupudi » Mon Jan 07, 2008 6:24 am

bKeyNo also
Regards

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

Postby James Bott » Mon Jan 07, 2008 7:16 am

Antonio,

I suggest that we add the following method to TXBrowse so we can more easily use it with database objects.

Regards,
James

Code: Select all  Expand view
METHOD SetoDBF( oDBF ) CLASS TXBrowse
   ::cAlias    := oDBF:cAlias
   ::bSkip     := {| n | oDBF:skipper( n ) }
   ::bGoTop    := {|| oDBF:GoTop() }
   ::bGoBottom := {|| oDBF:GoBottom()  }
   ::bBof      := {|| oDBF:Bof() }
   ::bEof      := {|| oDBF:Eof() }
   ::bBookMark := {| n | iif( n == nil,(oDBF:RecNo()),(oDBF:GoTo( n )) ) }
   ::bKeyNo    := ::bBookMark
   ::bKeyCount := {|| oDBF:RecCount()}
return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby nageswaragunupudi » Mon Jan 07, 2008 8:26 am

In line with other methods :
Code: Select all  Expand view
METHOD   SetoDbf( oDbf ) CLASS TXBrowse

   DEFAULT ::bGoTop    := {|| oDbf:GoTop() },;
           ::bGoBottom := {|| oDbf:GoBottom()  },;
           ::bSkip     := {| n | oDbf:Skipper( iif( n == nil,1,n) )}, ;
           ::bBof      := {|| oDbf:Bof() },;
           ::bEof      := {|| oDbf:Eof() },;
           ::bBookMark := {| n | iif( n == nil,;
                                          (oDbf:RecNo()),;
                                          (oDbf:GoTo(n)) ) },;
           ::bKeyNo    :=::bBookMark,;
           ::bKeyCount := {|| oDbf:RecCount()}

   ::nDataType         := DATATYPE_ODBF  // if FWH agrees only
   ::oDbf              := oDbf

RETURN Self
Regards

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

Postby nageswaragunupudi » Mon Jan 07, 2008 8:29 am

I suggest not to assign alias, so that this method can serve any Data Class, whether the underlying data source is RDD or not.

For example, i use classes for arrays, text (sdf), ado ( wrapper class for recordset) and any other heterogenous data.

Better this method is generic as long as the Class provides the methods of goTop, goBottom, Skipper, bookmark. recno and goto
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 60 guests