Page 1 of 1

Xbrowse con Columna CheckBox - (Solucionado)

Posted: Tue Aug 13, 2013 10:42 pm
by leandro
Buenas noches a todo el foro:

Como dice el encabezado quiero colocar una columna con checkbox sobre una dbf, he leido muchos ejemplos en el foro pero todos estan sobre arrays
lo unico que encontre sobre una dbf es el siguiente codigo pero no logro hacerlo funcionar.

Code: Select all

FUNCTION pChebrowse()

local oDlg,oMvg1

DEFINE DIALOG oDlg NAME "orBuscar" ICON "#8001" TRANSPARENT

   REDEFINE BUTTONBMP Btn_Limp ID 4003 OF oDlg BITMAP "Blimpi2" TOOLTIP oLamcla:mTfil
   REDEFINE GET oBog1 VAR oMvg1 ID 4002 OF oDlg UPDATE

   REDEFINE SAY oSay ID 4004 PIXEL OF oDlg COLOR oLamcla:cClr5 PICTURE '@!'

   SELE d_ctasc
   dbappend()
   Dbgotop()
   oBrw := TXBrowse():New( oDlg )
   oBrw:nMarqueeStyle         := MARQSTYLE_HIGHLCELL //MARQSTYLE_HIGHLROW //
   oBrw:nColDividerStyle      := LINESTYLE_RAISED
   oBrw:nHeaderLines          := 1
   oBrw:lFooter               := .t.
   oBrw:nFooterLines          := 1
   oBrw:nFooterHeight         := 24
   oBrw:lColDividerComplete   := .t.
   oBrw:lRecordSelector       := .t.
   oBrw:bClrStd               := {|| IF( (Recno()%2)==0,{oLamcla:cClr5,oLamcla:cClr2},{oLamcla:cClr5,oLamcla:cClr1} ) }
   oBrw:bClrSel               := {|| { oLamcla:cClr5,oLamcla:cClr7 } }
   oBrw:bClrSelFocus          := {|| { CLR_WHITE,RGB(147,160,112) } }
   oBrw:lFastEdit             := .t.

       oCol  := oBrw:oCol( "Existe" )
       oCol:SetCheck( { "GREEN", "RED" }, {|o, v| (DBRLOCK(), d_ctasc->exist := v, DBUNLOCK() ) } )
       oCol:bStrData        := { || If( d_ctasc->exist, "Yes", "No" ) }
       oCol:nDataStrAlign   := AL_RIGHT

   oBrw:SetRDD()
   oBrw:CreateFromResource(102)


ACTIVATE DIALOG oDlg NOWAIT On Init (Centra( oDlg ),oDlg:refresh()) //VALID (pValCapSal(),.t.)
return nIL
 
Me dice que la función SetCheck no existe, alguien tiene un ejemplo...

Re: Xbrowse con Columna CheckBox

Posted: Tue Aug 13, 2013 11:30 pm
by Armando
Leandro:

Va un ejemplo con recordset pero fácilmente lo puedes adaptar a DBFs cambiando
el origen de los datos

Code: Select all

            aCol[ 7]                            := oBrw:AddCol()
            aCol[ 7]:AddResource("SI16")
            aCol[ 7]:AddResource("NO16")
            aCol[ 7]:cHeader                := "Can"
            aCol[ 7]:bBmpData               := { || IF(oRsHdr:RecordCount() > 0,IIF(oRsHdr:Fields("HDR_CAN"):Value,1,2),2) }
            aCol[ 7]:nHeadBmpAlign      := AL_RIGHT
 
Saludos

Re: Xbrowse con Columna CheckBox

Posted: Wed Aug 14, 2013 2:24 am
by leandro
Amigo buena noche, primero que todo muchas gracias por contestar.... Pero te cuento que adapte el código y no me funciono, así quedo:

Code: Select all

  oCol = oLamcla:oBrwCapt:AddCol()
   oCol:AddResource("BFLEC")
   oCol:AddResource("BEQUIS")
   oCol:cHeader      := "Activa"
   oCol:bBmpData            := { || IF(d_ctasc->exist,1,2) }
   oCol:nHeadBmpAlign      := AL_RIGHT
 
y esta es la imagen

Image

De Antemano Gracias

Re: Xbrowse con Columna CheckBox

Posted: Wed Aug 14, 2013 9:01 am
by vlmsoft
Hola Leandro

.....

REDEFINE XBROWSE oBrw ;
   ALIAS "Cliente" ;
   FIELDS Cliente->Codigo , ;
              Cliente->Nombre , ;
              Cliente->Baja ;
   ID 101 ;
   OF oDlg

....

oBrw:aCols[3]:SetCheck( { "CHECKON","CHECKOFF" } )

*** CHECKON y CHECKOFF son dos bitmaps almacenados en un fichero de recursos


Un saludo

Re: Xbrowse con Columna CheckBox

Posted: Wed Aug 14, 2013 9:29 am
by nageswaragunupudi
Mr Leandro

oBrw:SetRDD() should immediately follow oBrw := TXBrowse():New(oDlg ).
Then you would not get this error.

As long as you use this syntax for creation of XBrowse, you are likely to get into some other other errors or unable to avail most features of Xbrowse.

We highly recommend using command syntax.

In your example:

Code: Select all

REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc" AUTOCOLS ;
   CELL LINES FOOTERS FASTEDIT

oBrw:oCol( "Exist" ):SetCheck( { "GREEN", "RED" }, .t. )

<other clauses>

ACTIVATE DIALOG oDlg ........... <other clauses>
 
The above code would have done what you wanted.

Re: Xbrowse con Columna CheckBox

Posted: Wed Aug 14, 2013 10:56 am
by leandro
Thanks for answering Mr. Nao and vlmsoft

But I get the following error

Code: Select all

Descripción del Error:
___________________________________________________

Error BASE/1004
Class: 'NIL' has no exported method: SETCHECK
   Args:
     [   1] = U
     [   2] = A   { ... }
     [   3] = L   .T.
 
so stay the code

Code: Select all

FUNCTION pChebrowse()

local oDlg,oMvg1

DEFINE DIALOG oDlg NAME "orBuscar" ICON "#8001" TRANSPARENT

   REDEFINE BUTTONBMP Btn_Limp ID 4003 OF oDlg BITMAP "Blimpi2" TOOLTIP oLamcla:mTfil
   REDEFINE GET oBog1 VAR oMvg1 ID 4002 OF oDlg UPDATE

   REDEFINE SAY oSay ID 4004 PIXEL OF oDlg COLOR oLamcla:cClr5 PICTURE '@!'

   SELE d_ctasc
   dbappend()

   Dbgotop()
   oBrw := TXBrowse():New( oDlg )


   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc" AUTOCOLS ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "Cambia" ):SetCheck( { "GREEN", "RED" }, .t. )

   oBrw:SetRDD()


ACTIVATE DIALOG oDlg NOWAIT On Init (Centra( oDlg ),oDlg:refresh()) //VALID (pValCapSal(),.t.)
return nIL
 

Re: Xbrowse con Columna CheckBox

Posted: Wed Aug 14, 2013 11:13 am
by nageswaragunupudi
What is the exact spelling of the field "Cambia" ?
If there is no field by name "cambia" you will get this error.
Please post dbstruct() of the dbf that is opened with the alias "d_ctasc"

Re: Xbrowse con Columna CheckBox

Posted: Thu Aug 15, 2013 2:04 am
by leandro
Mr. Nao Thank's for answer

The structure is as follow

Code: Select all

IF !FILE (".\dbfs\lamtem\ctas.DBF")
   DbCreate( ".\dbfs\lamtem\ctas",{   { "cuent"  ,"C",  10, 0 },;
                                                  { "nombr"  ,"C",  50, 0 },;
                                                  { "exist"    ,"L",   1,  0 } } )
ENDIF
 
"Cambia" = exist->d_ctasc

Re: Xbrowse con Columna CheckBox

Posted: Thu Aug 15, 2013 8:02 am
by nageswaragunupudi

Code: Select all

   USE (".\dbfs\lamtem\ctas.DBF") NEW ALIAS SHARED d_ctasc

   < ... your other code ..>

   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc"  ;
   COLUMNS "cuent", "nombre", "exist" ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "exist" ):SetCheck( { "GREEN", "RED" }, .t. )
 
You can refer to a column with oBrw:oCol( <cheader> ) OR oBrw:oCol( 3 ) ( creation order number. In the above case header of 3rd column is "exist" by default and not "Cambia"

If you specify different headers like this then you should use the header name

Code: Select all

   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc"  ;
   COLUMNS "cuent", "nombre", "exist" ;
   HEADERS "Cuentxxx", "Nombrexxx", "Cambia" ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "Cambia" ):SetCheck( { "GREEN", "RED" }, .t. )
 

Re: Xbrowse con Columna CheckBox

Posted: Thu Aug 15, 2013 9:02 pm
by leandro
Mr NAO, muchas gracias por responder, al rato lo reviso y te comento.

Saludos

Re: Xbrowse con Columna CheckBox

Posted: Fri Aug 23, 2013 11:21 pm
by leandro
Thanks Mr. NAO, worked very well. :D