Spinner in grid

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Spinner in grid

Post by danielmaximiliano »

Hola a todos :
tengo un problema en mi aplicacion Punto de venta (POS)
les comento, los articulos se cargan mediante un textbox que toma lo ingresado con el lector de barra estos se cargan en un grid.
el ejemplo reproduce el posible error que les comento para que puedan reproducirlo.
el array aItems carga el producto con un nombre y una cantidad (en este caso una unidad) que despues se puede modificar con un spinner , si modifico esta cantidad superior a 1 este muestra la nueva cantidad y es validado con COLUMNVALID

Code: Select all

COLUMNVALID	   {  Nil  , {|| if ( This.CellValue > 1 ,  msgbox( This.CellValue )  , nil ) } }
2021-01-07 23_10_13-Window.png
2021-01-07 23_10_13-Window.png (10.52 KiB) Viewed 1587 times
2021-01-07 23_12_11-DEBUG INFO.png
2021-01-07 23_12_11-DEBUG INFO.png (11.55 KiB) Viewed 1587 times
si voy a una rutina donde actualiza la cantidad la suma sigue siendo la cantidad inicial :? , si agrego un boton llamando a la misma rutina recien ahi la suma es correcta o por segunda vez modifico la cantidad con el spinner-
en que fallo ? :oops:

Hello everyone :
I have a problem in my Point of Sale (POS) application
I comment, the articles are loaded through a textbox that takes what was entered with the bar reader, these are loaded into a grid.
The example reproduces the possible error that I am telling you so that you can reproduce it.
the array aItems [/ b] loads the product with a name and a quantity ( in this case a unit [/ b]) that can later be modified with a spinner [/ b], if I modify this quantity higher than 1 this shows the new quantity and is validated with COLUMNVALID [/ b]

Code: Select all

COLUMNVALID	   {  Nil  , {|| if ( This.CellValue > 1 ,  msgbox( This.CellValue )  , nil ) } }
2021-01-07 23_10_13-Window.png
2021-01-07 23_10_13-Window.png (10.52 KiB) Viewed 1587 times
2021-01-07 23_12_11-DEBUG INFO.png
2021-01-07 23_12_11-DEBUG INFO.png (11.55 KiB) Viewed 1587 times
if I go to a routine where it updates the amount the sum is still the initial amount:? , if I add a button calling the same routine just there the sum is correct or for the second time I modify the amount with the spinner-
in what fault? :oops:
GRID_14.rar
(1.61 KiB) Downloaded 87 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Spinner in grid

Post by SALINETAS24 »

danielmaximiliano wrote: Fri Jan 08, 2021 2:22 am Hola a todos :
tengo un problema en mi aplicacion Punto de venta (POS) .......
l

Hola Daniel, el GRID tiene su propia array y tienes que forzar su actualización, en caso contrarío siempre mostará su carga inicial.

Te paso la posible solución.

Un saludo, frio .., muy frio.., hace tanto frio que no hace falta sacar la cervecita de la nevera. :lol:
Attachments
DEMO.rar
(1.21 MiB) Downloaded 93 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Spinner in grid

Post by danielmaximiliano »

Hola Salinetas: Si, funciona.
debe ser un error que arrastra el grid, ya que Columnvalid muestra el valor actual de la celda pero el contenido del
array no :roll: ya que el ejemplo es simple y claro

Hello Salinetas: Yes, it works.
it must be an error dragging the grid, since Columnvalid shows the current value of the cell but the content of the
array no: roll: since the example is simple and clear

************************************************************************************************************************************************

Mi codigo corregido gracias a tu ayuda es el siguiente .
My corrected code thanks to your help is the following.

Code: Select all

COLUMNVALID	{ ;
					{ || if ( This.CellValue > 1 ,  Actualiza() , nil ) } , ;
					Nil , ;
					Nil , ;
					Nil , ;
					Nil ;
					}

Code: Select all

*----------------------------------------------------------------------------*
Procedure ActualizaVenta()
*----------------------------------------------------------------------------*
Local aItem := {}
Local nItem
 Ventas.Text_1.Value             := '0'                                             
 Ventas.nTotalArt.Value          := 0                                              
 Ventas.nTotal.Value             := 0.0  
 
    For nItem := 1 to Ventas.Articulos.ItemCount  
       aItem := Ventas.Articulos.item ( nItem )
       Ventas.nTotalArt.Value  := Ventas.nTotalArt.Value + aItem[1]
	   Ventas.nTotal.Value	   := Ventas.nTotal.Value	 + aItem[5] 
	Next 
   
      Ventas.Articulos.Refresh
      Ventas.Text_1.SetFocus      // Dont work
Return

Procedure Actualiza()
Local nItem                    := Ventas.Articulos.Value
Local aProducto                := Ventas.Articulos.item ( nItem )
aProducto[1]                   := This.CellValue
aProducto[5]                   := aProducto[1] * aProducto[4]     
Ventas.Articulos.item ( nItem ):= aProducto
ActualizaVenta()

RETURN
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Spinner in grid

Post by danielmaximiliano »

Hola a todos de nuevo :
corregido el inconveniente que tenia tengo una nueva pregunta..... al terminar de modificar la cantidad de ese producto y actualizar el Ticket de venta el foco se devuelve al TextBox de ingreso de datos.
Resulta que el GRID queda iluminado en gris en el lugar donde se hizo la modificacion. ¿ se puede hacer que el grid no tenga esa propiedad ? ya que los productos mayores a 1 quedan marcados de color naranja

Hi again, everybody :
corrected the problem that I had I have a new question ..... when finishing modifying the quantity of that product and updating the Sales Ticket, the focus is returned to the data entry TextBox.
It turns out that the GRID is lit gray in the place where the modification was made. Can you make the grid not have that property? since products greater than 1 are marked in orange
2021-01-08 09_07_58-Window.png
2021-01-08 09_07_58-Window.png (12.83 KiB) Viewed 1532 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Spinner in grid

Post by andyglezl »

Hola Max
Creo de deberás utilizar : DYNAMICBACKCOLOR
*-------------------------------------------------------------------
hi Max
I think you should use: DYNAMICBACKCOLOR

Code: Select all

fColor  := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , IF( DELETED() , CLRERROR , WHITE ) , IF( DELETED() , CLRERROR , NJAPAST ) ) }
afColor := ARRAY( nCpos )
AFILL( afColor, fColor )

		aColWhen[ 1 ] := { | | .F. }	// El primer campo es READONLY
		@ 030 , 005 GRID   Grid_2 OF Form_GridCtes WIDTH 1008 HEIGHT 505 FONT "Consolas" SIZE 11 FONTCOLOR BLACK 	;
					ROWSOURCE "Ctes" VALUE { 1, 1 } WIDTHS aLong HEADERS aCpos1 COLUMNFIELDS aCpos2 COLUMNCONTROLS aColCtrls  ; 
					ON HEADCLICK { { || Ctes->( DBSetOrder( 1 ), DoMethod( 'Form_GridCtes', "Grid_2", "Refresh", .T. ) ) },  ;
								   { || Ctes->( DBSetOrder( 2 ), DoMethod( 'Form_GridCtes', "Grid_2", "Refresh", .T. ) ) } }	;
					EDIT ALLOWAPPEND ALLOWDELETE EDITOPTION GRID_EDIT_DEFAULT	   ;				
					COLUMNWHEN aColWhen	DYNAMICBACKCOLOR afColor ON CHANGE OnChangeGrid( )	ON KEY OnDeleteGrid( )	ON 						
					SAVE OnSaveGrid( )
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Spinner in grid

Post by danielmaximiliano »

andyglezl wrote: Fri Jan 08, 2021 5:20 pm Hola Max
Creo de deberás utilizar : DYNAMICBACKCOLOR
Ya lo utilizé, pero al pintar y después que el textbox toma el foco queda en gris esa fila del grid ya que quedó el anterior foco
ahi le hice las modificaciones al ejemplo y veras que al modificar la cantidad y darle foco al textbo total el grid queda iluminado
y no se nota la modificacion en color
GRID_14.rar
(3.38 KiB) Downloaded 87 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Spinner in grid

Post by SALINETAS24 »

by danielmaximiliano » Fri Jan 08, 2021 12:14 pm

Hola a todos de nuevo :
corregido el inconveniente que tenia tengo una nueva pregunta..... al terminar de modificar la cantidad de ese producto y actualizar el Ticket de venta el foco se devuelve al TextBox de ingreso de datos.
Muy buenas.

Esta es la solución que yo he podido desarrollar, como verás he incorporado un nuevo PROCEDIMIENTO, que se llama QUITAFOCUS() :lol: y para lograr el efecto deseado (o que se aproxime), no hace otra cosa que crear un ITEM y BORRARLO, cada vez que quiero perder el foco. :shock: Por suerte se trabaja muy rápido con los arrays.

Yo creo que tiene que haber una posibilidad de situar el cursor sin necesidad de Crear y Borrar el ITEM, y que debe estar en h_grid.prg ..... o eso me lo imagino yo. ;)

En fin, lo bueno que tiene esto .. es que con imaginación puedes hacer muuuuccchhhaaaass cosas. 8-)

Un saludo y ahora si que me tomo la cervecita fresquita....
Attachments
DEMO.rar
(1.21 MiB) Downloaded 86 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Spinner in grid

Post by danielmaximiliano »

SALINETAS24 wrote: Fri Jan 08, 2021 11:04 pm he incorporado un nuevo PROCEDIMIENTO, que se llama QUITAFOCUS() :lol:
:lol: QUITAFOCUS()

muy buenoooo!!!. yo estaba por eliminar el spinner poner LABEL en forma de cuadriculas desde el 1 al 24 (maximo de articulos) para despues introducir con el lector el articulo de esa forma evitar el FOCUS sobre el grid.

en la carga del GRID y al agregar un ITEM no aparece ningun FOCUS sobre el mismo, intente por Form_1.Grid_1.Value := 0
y hacer un REFRESH sin ningun resultado :?

mi codigo actualizado

Code: Select all

Proc QuitaFocus()
PRIVATE aVar[5], nPos

	aVar[1]:= 0
	aVar[2]:= ""
	aVar[3]:= ""
	aVar[4]:= 0
	aVar[5]:= 0
	nItem  := GETPROPERTY( "Ventas"   , "Articulos" , "ItemCount"   )
	DoMethod(    "Ventas", "Articulos", "ADDITEM"   , aVar          )
	SETPROPERTY( "Ventas", "Articulos", "VALUE"     , nItem+1       ) 
	DOMETHOD(    "Ventas","Articulos" , "DELETEITEM", ( nItem + 1 ) ) 
RETURN	
gracias Salinetas unas Brahmas a la distancia.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Spinner in grid

Post by AUGE_OHR »

hi,

your need that "Trick" while "Focus" is "on Item" and "Cursor" hide Dynamic Color.
IMHO you need to de-hilite "select Item" to see Color
DELITE.ZIP
(1.84 KiB) Downloaded 95 times
---

i have use ONCHANGE of GRID to "refresh" TEXTBOX Total
for this i have to "move" TEXTBOX before GRID
have fun
Jimmy
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Spinner in grid

Post by danielmaximiliano »

AUGE_OHR wrote: Sat Jan 09, 2021 2:23 am hi,

your need that "Trick" while "Focus" is "on Item" and "Cursor" hide Dynamic Color.
IMHO you need to de-hilite "select Item" to see Color

DELITE.ZIP

---

i have use ONCHANGE of GRID to "refresh" TEXTBOX Total
for this i have to "move" TEXTBOX before GRID
Thanks Jimmy for sharing.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Post Reply