Page 1 of 3

move a record from xbrowse

PostPosted: Sun Nov 08, 2015 9:02 pm
by Silvio.Falconi
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

Re: move a record from xbrowse

PostPosted: Mon Nov 09, 2015 11:32 am
by Antonio Linares
Silvio,

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

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 12:03 pm
by Silvio.Falconi
I think it can be hard to create ...

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 1:51 pm
by ukoenig
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

Image

best regards
Uwe :roll:

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 2:57 pm
by FranciscoA
I'm traying it, also. With arrays.

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 3:58 pm
by joseluisysturiz
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:

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 6:35 pm
by FranciscoA
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?

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 8:16 pm
by joseluisysturiz
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... :shock:

Re: move a record from xbrowse

PostPosted: Tue Nov 10, 2015 10:38 pm
by Antonio Linares
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 ?

Image

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 12:23 am
by Otto
Dear Antonio,
what you see is from kinetic behavior.


Best regards,
Otto

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 1:00 am
by nageswaragunupudi
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: Select all  Expand view

#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
 

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 3:01 am
by FranciscoA
Thanks, Rao.

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

Best regards.

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 9:35 am
by elvira
Mr. Nages,

Can we please have this sample with a DBF?.

Thank you.

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 12:22 pm
by nageswaragunupudi
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 .

Re: move a record from xbrowse

PostPosted: Wed Nov 11, 2015 12:26 pm
by nageswaragunupudi
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.