FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Editar celda xBrowse
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Editar celda xBrowse
Posted: Fri Oct 22, 2021 02:29 AM
Saludos,

Tengo este pequeño codigo de prueba con xBrowse

Code (fw): Select all Collapse
   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
"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Editar celda xBrowse
Posted: Fri Oct 22, 2021 11:32 AM
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Editar celda xBrowse
Posted: Fri Oct 22, 2021 12:30 PM
Creo que con esto te servirá
Code (fw): Select all Collapse
     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
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Editar celda xBrowse
Posted: Fri Oct 22, 2021 03:54 PM

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.

"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Editar celda xBrowse
Posted: Thu Oct 28, 2021 01:17 AM
Recommended:

Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion