FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour move a record from xbrowse
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
move a record from xbrowse
Posted: Sun Nov 08, 2015 09:02 PM

it is possible move a record from position x to position y into a xbrowse
because my customer want the possibility to move a record into a table of order ( made with xbrowse) to another position
the customer let me see an old prg made in vb6 he moved the record taking with the mouse and press on recordselector and move it into another position
my customer sad me need it to group products and comments

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: move a record from xbrowse
Posted: Mon Nov 09, 2015 11:32 AM

Silvio,

Surely Rao will provide us here the best advise to do it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 12:03 PM

I think it can be hard to create ...

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 01:51 PM
Silvio,

I have the same problem changing the position.

My solution for the moment :
selecting the 2 records I want to change the position.
Doing the change on button-click
Now the COMPLETE records are changing the position



best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 02:57 PM

I'm traying it, also. With arrays.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 03:58 PM

Disculpen mi ignorancia, si es con un array no seria mas facil si solo le cambian el valor a oBrw:nArrayAt en ambos lados con el juego de 3 casillas.? digo, si es que se le puede reasignar el valor a nArrayAt y luego hacer un refresh.
La otra idea es crear un registro en blanco, copiar alli uno de los registros, reemplazar los valores a uno de los registros por el que se quiere cambiar, luego copiar el del registro nuevo al cambiado y por ultimo borrar el registro nuevo dublicado...nose si es una loquera lo que digo, solo lo veo en forma de SEUDOCOIDE, habria que ver si es factible en codigo, saludos... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 06:35 PM
Silvio wrote: ...the customer let me see an old prg made in vb6 he moved the record taking with the mouse and press on recordselector and move it into another position


José Luis.
La pregunta es: ¿Cómo hacerlo con Drag and Drop?
The question is: How to do it using Drag and Drop?
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 08:16 PM
FranciscoA wrote:
Silvio wrote: ...the customer let me see an old prg made in vb6 he moved the record taking with the mouse and press on recordselector and move it into another position


José Luis.
La pregunta es: ¿Cómo hacerlo con Drag and Drop?
The question is: How to do it using Drag and Drop?


Ha bueno, ya eso es otra cosa, yo lo vi solo como un intercambio de posiciones, no por DRAG/DROP.? ya aca debera ver nuestro Mr.Noa o Daniel o AL, que son mas expertos, digo yo ..nose..solo fue una loca idea que se me vino, saludos... :-)
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: move a record from xbrowse
Posted: Tue Nov 10, 2015 10:38 PM
Silvio,

If I click on a row and keep the mouse pressed and move it downwards, then two selected
records appear. Could you try this on your browses and let me know if you get it too ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 12:23 AM

Dear Antonio,
what you see is from kinetic behavior.

Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 01:00 AM
This is an example of moving a row from one position to another position by drag and drop. This is demonstrated with an array
Code (fw): Select all Collapse
#include "fivewin.ch"

function main()

   local oDlg, oBrw, oFont, oCur, aData[ 12 ]

   AEval( aData, { |u,i| aData[ i ] := NtoCMonth( i ) } )

   DEFINE CURSOR oCur DRAG
   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 250,500 PIXEL FONT oFont
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE aData COLUMNS 1 CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol      := 1
      :oDragCursor      := oCur
      :bDragBegin       := { |r,c,f,o| SetDropInfo( { oBrw:nArrayAt, oBrw:aRow } ) }
      :bDropOver        := { |u,r,c,f| oBrw:LButtonDown( r,c ), ;
                                       oBrw:LButtonUp(), ;
                                       aDel( aData, u[ 1 ] ), ;
                                       AIns( aData, oBrw:nArrayAt, u[ 2 ] ), ;
                                       oBrw:Refresh() }

      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   RELEASE CURSOR oCur

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 03:01 AM

Thanks, Rao.

I tried it and it works well for me.
Tomorrow I will do more tests on medium and large arrays.

Best regards.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 09:35 AM

Mr. Nages,

Can we please have this sample with a DBF?.

Thank you.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 12:22 PM
FranciscoA wrote:Thanks, Rao.

I tried it and it works well for me.
Tomorrow I will do more tests on medium and large arrays.

Best regards.

This is a very simple case, works only when the start and destination are both visible on the same screen. This example also does not have any error handling. In real life we may need to handle scrolling also if the destination is several rows away.
This should serve as a simple example to form the basis of a complex final product.

Cut and Paste instead of Drag and Drop:
Instead of using Drag/Drop, we can also use Cut and Paste. Cut the source record, navigate to the new position and then move the record there .
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: move a record from xbrowse
Posted: Wed Nov 11, 2015 12:26 PM
elvira wrote:Mr. Nages,

Can we please have this sample with a DBF?.

Thank you.

This xbrowse example, after the end of the drag, informs the programmer, start record number and destination record number. The programmer has to decide if he wants to swap data of some fields between these two records or wants a visual re-ordering of the rows where the moved record appears in the new position.

First thing to decide is how the programmer wants to record the change in the dbf. Once that is clear, it can be plugged into the bDropOver.
Regards



G. N. Rao.

Hyderabad, India