Mr. Rao, more about xBrowse

Post Reply
User avatar
Armando
Posts: 3271
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 2 times
Contact:

Mr. Rao, more about xBrowse

Post by Armando »

Mr. Rao:

I have the following code, I need the same code for all the columns of the browse, something like :nEditTypes := 1, I know that I can repeat it as many columns as the browse has, the problem is that I don't know how many columns the browse has.

Code: Select all | Expand

            WITH OBJECT :aCols[03]
               :bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
               :bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) } 
               :bEditValid := { | oGet | Valida(oGet:VarGet())}         
            END
 
I am building the browse with the code AUTOCOLS


Thank you for your kind help

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: Mr. Rao, more about xBrowse

Post by cmsoft »

Podria ser algo asi:

Code: Select all | Expand

for each oCol in :aCols
      oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
next oCol
User avatar
Armando
Posts: 3271
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 2 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by Armando »

Cesar:

Gracias por la idea, pero me tira error, no reconoce oCol

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: Mr. Rao, more about xBrowse

Post by cmsoft »

Fijate si algo asi es la idea
Tenias razon, lo otro daba error

Code: Select all | Expand

#include "Fivewin.ch"
#include "xbrowse.ch"
static nSaldo, oSay 
FUNCTION cmsoft()
LOCAL oDlg1, oBrwTmp, aCols, oCol, nFilas := 3, nColumnas := 3, i, j 
nSaldo := 10000
MsgGet("Filas","Ingrese filas",@nFilas)
MsgGet("Columnas","Ingrese columnas",@nColumnas)
aCols := ARRAY(nFilas,nColumnas)
FOR i := 1 to nFilas 
    for j := 1 to nColumnas 
        aCols [i,j] := 0
    next j
next i
DEFINE DIALOG oDlg1 TITLE "Edicion" SIZE 700,700 PIXEL TRUEPIXEL RESIZABLE
   @ 20, 20 XBROWSE oBrwTmp SIZE -20,-20 pixel OF oDlg1 ;
      CELL LINES NOBORDER
   WITH OBJECT oBrwTmp
      :SetArray(aCols)
      AEval( :aCols, ;
         { |o| (o:bOnPreEdit := { | o, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !","Atencion"),)}), ;
               (o:bOnChange  := { | o, uOldVal| VerSaldo(uOldVal) }),;
               (o:bEditValid := { | oGet | Valida(oGet:VarGet())}),;
               (o:nEditType := EDIT_GET) })


      /*for each oCol in :aCols
            oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !","Atencion"),)}
            oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
            oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
            oCol:nEditType := EDIT_GET 
      next oCol      */
      :CreateFromCode()
   END
@ 0,0 Say "Saldo" GET oSay VAR nSaldo  PIXEL   OF oDlg1 READONLY
ACTIVATE DIALOG oDlg1 CENTERED 
RETURN nil

static function VerSaldo(n)
nSaldo := nSaldo + n
oSay:Refresh()
return nil 

static function valida(n)
IF (nSaldo - n) <= 0 
   MsgStop("El importe super el saldo")
   RETURN .f.
ENDIF 
nsaldo := nSaldo - n
oSay:Refresh()
return .t.
User avatar
Armando
Posts: 3271
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 2 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by Armando »

César:

Gracias, pruebo y aviso.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by nageswaragunupudi »

cmsoft wrote:Podria ser algo asi:

Code: Select all | Expand

for each oCol in :aCols
      oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
next oCol
XBrowse provides a much easier way.
No need for using "for each oCol in :aCols" or "AEval( :aCols.", etc.

Code: Select all | Expand

WITH OBJECT oBrw
      :bOnPreEdits := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      :bOnChanges  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      :bEditValids := { | oGet | Valida(oGet:VarGet())}
END
Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 3271
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 2 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by Armando »

Mr. Rao (Master)

It works soo fine.

Thanks so much.

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: Mr. Rao, more about xBrowse

Post by cmsoft »

Muchas gracias por la aclaración, mucho mas facil así. Cada dia me sorprendo mas del poder de xbrowse!!
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by nageswaragunupudi »

Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
If we want to set the same value for any DATA of every column, we use

Code: Select all | Expand

oBrw:datas := uValue
If we want to set different values like [ a, b, c, d, ... } to each column in the creation order we use

Code: Select all | Expand

oBrw:datas := { a, b, c, .... }
Examples:

Code: Select all | Expand

oBrw:nEditTypes := EDIT_GET
oBrw:cSortOrders := { "ID","FIRST","LAST", ... }
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 3271
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 2 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by Armando »

Mr. Rao:

Thanks so much.

With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Mr. Rao, more about xBrowse

Post by Marc Venken »

nageswaragunupudi wrote:
cmsoft wrote: Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
Out of interest : In the source class, i don't see these data as plural ? how does Xbrowse know them ?

like :

oBrw:nEditTypes := EDIT_GET
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Mr. Rao, more about xBrowse

Post by nageswaragunupudi »

XBrowse is not that simple class.
Well all this is handled in the Error Handler.

There is no DATA nEditTypes in XBrowse, so this message goes to error handler.
There it checks if there is any data of a Column class with that name without trailing "s"
If exists then the rest of the logic is simple.
Regards

G. N. Rao.
Hyderabad, India
Post Reply