Page 1 of 1

Editar celda xBrowse

PostPosted: Fri Oct 22, 2021 2:29 am
by JoseAlvarez
Saludos,

Tengo este pequeño codigo de prueba con xBrowse

Code: Select all  Expand view
  REDEFINE XBROWSE oBrw Id 10  DATASOURCE oArticulos             ;
                                FIELDS     oArticulos:descripcion ;
                                HEADERS    "Descripcion"          ;
                                FIELDSIZES  350                   ;
                                JUSTIFY     AL_LEFT               ;
                                CELL LINES                        ;
                                of oDlg_Articulos  
                                WITH object oBrw
                                        oBrw :l2007           := .t.                        
                                        oBrw :lRecordSelector := .t.                        
                                        oBrw :aCols[1]        :nHeadStrAlign := AL_CENTER  
                                        oBrw :aCols[1]        :oHeaderFont   := oFontHeader  
                                        oBrw :oDataFonts      :=oFontData                    
                                END
                                oArticulos:Gotop()
                                oBrw:Refresh()
 


Quiero poder Editar y Cambiar el Valor de cualquier celda de esa columna,

¿Que debo Hacer?

¿ese cambio afecta la tabla directamente o actua sobre el arreglo resultado de la consulta?

Necesito que NO afecte la tabla directamente. Discupen la pregunta, pero no se como actua xBowse en esos casos

Re: Editar celda xBrowse

PostPosted: Fri Oct 22, 2021 11:32 am
by leandro

Re: Editar celda xBrowse

PostPosted: Fri Oct 22, 2021 12:30 pm
by cnavarro
Creo que con esto te servirá
Code: Select all  Expand view

     oCol:nEditType := EDIT_GET
 

aunque seguramente tendrás que añadir también en la definición del xbrowse la clausula FASTEDIT
Una vez que puedas editar, tendrás que aplicar algunas de las acciones que te comenta el compañero Leandro en el post anterior

Re: Editar celda xBrowse

PostPosted: Fri Oct 22, 2021 3:54 pm
by JoseAlvarez
Leandro, Cristobal,

Listo amigos, ya lo hice andar,

Gracias a Ambos.

Decidi ya dejar la twbrowse del amigo cecarelli, la cual me acompaño por muchos años y pasarme a xBrowse, asi que los estare molestando con algunas cosillas mas...

Muchas gracias por su ayuda.

Re: Editar celda xBrowse

PostPosted: Thu Oct 28, 2021 1:17 am
by nageswaragunupudi
Recommended:

Code: Select all  Expand view

REDEFINE XBROWSE oBrw Id 10 ;
   OF oDlg_Articulos ;
   DATASOURCE oArticulos ;
   COLUMNS "Descripcion" ; //FIELDS oArticulos:descripcion HEADERS "Descripcion"          ;
   FIELDSIZES  350 ; // JUSTIFY AL_LEFT
   FONT oFontData ;
   CELL LINES ;
   FASTEDIT // optional

   WITH object oBrw
      // :l2007            := .t.
      // :lRecordSelector  := .t.
      WITH OBJECT :aCols[ 1 ]
         :nHeadStrAlign := AL_CENTER
         :oHeaderFont   := oFontHeader
         :nEditType     := EDIT_GET   //
      END
   END
   oArticulos:Gotop()
   // oBrw:Refresh() // remove this line
   ACTIVATE DIALOG oDlg_Atriculos
 


1) Do not use FIELDS clause. Use COLUMNS clause. In the COLUMNS clause, provide the names of the fields as strings.
2) Do not use bStrData and bOnPostEdit. Their usage was deprecated many years ago.


Quiero poder Editar y Cambiar el Valor de cualquier celda de esa columna,
¿Que debo Hacer?

English:
I want to be able to Edit and Change the Value of any cell in that column, What should I do?

This is enough.
Code: Select all  Expand view

oBrw:aCols[ 1 ]:nEditType := EDIT_GET
 

This is the line that enables editing the value in the cell and save it to the table.
User can directly type into the cells and make changes.

¿ese cambio afecta la tabla directamente o actua sobre el arreglo resultado de la consulta?
ENGLISH
Does this change affect the table directly or does it act on the array resulting from the query?


All changes are saved immediately to the table on the Server.

I undertanad oArticulos as TDolphin Query.

Spanish
Necesito que NO afecte la tabla directamente.

ENGLISH
I need it to NOT affect the table directly.


If you are using TDolphin, read the data into an array and then Browse the array like this.

Code: Select all  Expand view

REDEFINE XBROWSE oBrw Id 10 ;
   OF oDlg_Articulos ;
   DATASOURCE aArray ;
   COLUMNS 1 ;
   HEADERS "Descripcion" ;
   <...other clauses...>
 


If you are using FWH built-in library, this is not necessary.
Simply set
Code: Select all  Expand view

oArticulos:SetBatchMode( .t. )
 

All changes made are retained in the memory only and are not written to the real table.
Later, if you want to save all the changes to the server at once, then call oArticulos:SaveBatch() and otherwise simply ignore the changes.