Page 1 of 2

xBrowse

PostPosted: Wed Sep 14, 2011 5:06 am
by Bayron
Hi all,

Using a DBF with no index...

Which is the rigth way to programatically delete the current record from a Browse???

oBrw:Delete() does not seem to doit for me...

Re: xBrowse

PostPosted: Wed Sep 14, 2011 7:57 am
by Otto
Do you have SET DELETED ON in your code?

Best regards,
Otto

Re: xBrowse

PostPosted: Wed Sep 14, 2011 11:59 am
by nageswaragunupudi
Code: Select all  Expand view
( oBrw:cAlias )->( DbDelete() )
oBrw:Refresh()

Re: xBrowse

PostPosted: Wed Sep 14, 2011 4:02 pm
by Bayron
Otto wrote:Do you have SET DELETED ON in your code?


Thanks Otto, Yes It's ON

Code: Select all  Expand view
( oBrw:cAlias )->( DbDelete() )
oBrw:Refresh()


Thanks Mr. Rao, It worked as I needed after a few changes in my other code...

Amazingly I did not find It's correct use, on a quick lookup... But I knew that you had the right solution, next time I am going to start by reading your post's...

Re: xBrowse

PostPosted: Wed Sep 14, 2011 5:42 pm
by Bayron
After deleting a random row, I get this visual problem now:
Image
I achieve the effect using :bClrStd

Is there a way to refresh the colors of the browse???

.OR.

I tried to avoid this not turning SET DELETED ON, but the row does not appears DISABLED as it should be, and the button in that deleted row still works, and the text is still shown as Non Deleted.

Is there a way to show it disabled????

Re: xBrowse

PostPosted: Wed Sep 14, 2011 6:25 pm
by Antonio Linares
Bayron,

I achieve the effect using :bClrStd


Please post the code you use for bClrStd, thanks

Re: xBrowse

PostPosted: Wed Sep 14, 2011 6:28 pm
by Bayron
Code: Select all  Expand view
:bClrStd  := { || If( Eval( ListVen:bKeyNo,,ListVen ) % 2 == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }

Re: xBrowse

PostPosted: Wed Sep 14, 2011 8:05 pm
by nageswaragunupudi
oBrw:KeyNo() returns the OrdKeyNo() as returned by the RDD. Less known is the fact that OrdKeyNo() returns correct serial number only when FILTER is set on ".NOT. DELETED()" when SET DELETED is ON.

So,
USE <dbf>
SET DELETED ON !DELETED()
GO TOP

Then browse as usual.

Re: xBrowse

PostPosted: Wed Sep 14, 2011 9:23 pm
by Bayron
Code: Select all  Expand view
SET DELETED ON !DELETED()

Does not work on FWH10.2 and xHarbour 1.21...
I also tried:
Code: Select all  Expand view
SET DELETED ON
SET FILTER TO !DELETED()


Anyhow, xBrowse is behaven normally...
The problem is that each line is painted before a row is deleted... and when oBrw:Refresh() is called, :bClrStd is not Evaluated and Repainted again...

So if there is not an easy solution ?????? I think I am just going to have to paint a single color in the browse...

Which leads to my next question:

Is there a way to paint the Browse Client Area when the Database is Empty??? Right now is ALL WHITE...

Re: xBrowse

PostPosted: Wed Sep 14, 2011 11:09 pm
by Antonio Linares
Bayron,

Use that FOR ... condition to create the index:

INDEX ON ... FOR ! Deleted() ...

example:
Code: Select all  Expand view
     INDEX ON Name TAG "Name" ;
         TO ( cPath + "\Test" ) FOR ! Test->( Deleted() )

Re: xBrowse

PostPosted: Thu Sep 15, 2011 2:29 am
by Bayron
Thanks for taking the time to answer my post, but the problem is not about the Deleted Records, but is that when I delete a record, the color of that row is lost and I get two consecutive rows with the same color....As you can see the above picture...

Re: xBrowse

PostPosted: Thu Sep 15, 2011 3:57 am
by nageswaragunupudi
Here is a working sample:
Please adopt this logic to your case.
Code: Select all  Expand view
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oFont

   SET DELETED ON

   USE CUSTOMER
   SET FILTER TO !DELETED()
   GO TOP

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      COLUMNS "First", "City", "State", "Salary" ;
      ALIAS 'CUSTOMER' CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, If( oBrw:KeyNo() % 2 == 0, RGB(224,236,255), RGB(189,211,253) ) } }
      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw:cAlias)->( BrwDelete( oBrw ) ), nil ) }
   END


   oBrw:CreateFromCode()
   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont


return (0)

//----------------------------------------------------------------------------//

static function BrwDelete( oBrw )

   if DbrLock()
      DELETE
      DbUnlock()
      SKIP
      if ( eof() )
         GO BOTTOM
      endif
      oBrw:Refresh()
   endif

return nil

//----------------------------------------------------------------------------//
 

Re: xBrowse

PostPosted: Thu Sep 15, 2011 3:58 am
by nageswaragunupudi
FiveWin, One line of code and it's done...


Well Said !!!!

Re: xBrowse

PostPosted: Thu Sep 15, 2011 4:26 am
by nageswaragunupudi
Is there a way to paint the Browse Client Area when the Database is Empty??? Right now is ALL WHITE...

As of now, no.
You may try having one blank record to get the effect you want.

Re: xBrowse

PostPosted: Thu Sep 15, 2011 4:29 am
by Bayron
Thanks for your answer, I do use basicly the same logic, but as I said before
The problem is not about the Deleted Records, but is that when I delete a record, the color of that row is lost and I get two consecutive rows with the same color....As you can see the above picture...


I think the problem is with the painting, when I use oBrw:Refresh() :bClrStd is not Evaluated and Repainted again...

I am just going to set the browse records on a single color... to avoid all of the trouble...