Error XBrowse edit_listbox

Error XBrowse edit_listbox

Postby Ariel » Thu Oct 17, 2019 11:36 am

Hola,
Tengo un xbrowse de un array con 3 elementos por registros -> { codigo(Numerico), detalle(char), precio(numerico) }, por registro. la idea es que el usuario elija la tarifa y levante el detalle y precio, al poner el listbox en la primer columna y mostrar el texto lo hace bien, pero al seleccionar el item, me pone el detalle en la primer columna cuando deberia poner el id, el codigo que uso es :

WITH OBJECT oBrwPlan:Cod
:cDataType := "N"
:nEditType := EDIT_GET_LISTBOX // tampoco funciona o funciona igual mal con EDIT_LISTBOX
// :cEditPicture := "@z 9999"
:bEditWhen := { || LEN(oBrwPlan:aArrayData)>0.AND.oBrwPlan:aRow[03]==0 }
// :bEditValid := { | oGet, oCol | ValidaCodArt( oGet, oCol, oBrwArticulo, oSelf:cPathRs ) }
:aEditListTxt := ArrTranspose( aPlanes )[02]
:aEditListBound := ArrTranspose( aPlanes )[01]
:bOnPostEdit:= { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oCol:value:= xVal,;
oSelf:LoadItem( oBrwPlan, xVal ),;
AddRow( oBrwPlan ),;
oBrwPlan:SelectCol(01) ),) }
END
aPlanes:= { { id1, "texto1", 120.00 },
{ id2, "texto2", 220.00 },
....
{ idn, "texton", 520.00 } }
el array del xbrowse lo inicializo: aTarifa:= {{0, "", 0}}

Gracias
Ariel
 
Posts: 374
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: Error XBrowse edit_listbox

Postby Ariel » Thu Oct 17, 2019 2:34 pm

El ejemplo :
Code: Select all  Expand view

#INCLUDE "FiveWin.ch"
#INCLUDE "XBrowse.ch"

function Main()

   local oWnd, aLin := {{0,"",0}}, i, oBrw, oBtn
   local aTabla:= { {  1, "item  1",  1.00 },;
                    {  2, "item  2",  2.00 },;
                    {  3, "item  3",  3.00 },;
                    {  4, "item  4",  4.00 },;
                    {  5, "item  5",  5.00 },;
                    {  6, "item  6",  6.00 },;
                    {  7, "item  7",  7.00 },;
                    {  8, "item  8",  8.00 },;
                    {  9, "item  9",  9.00 },;
                    { 10, "item 10", 10.00 } }

   DEFINE WINDOW oWnd

   @ 10,10 XBROWSE oBrw OF oWnd ;
      AUTOCOLS ;
      HEADERS 'Cod', 'Description', 'Price' ;
      ARRAY aLin ;
      CELL LINES

   WITH OBJECT oBrw:Cod
         :cDataType := "N"
         :nEditType     := EDIT_LISTBOX
//                     :cEditPicture := "@z 9999"
         :bEditWhen    := { || LEN(oBrw:aArrayData)>0.AND.oBrw:aRow[03]==0 }
//                     :bEditValid    := { | oGet, oCol | ValidaCodArt( oGet, oCol, oBrwArticulo, oSelf:cPathRs ) }
         :aEditListTxt   := ArrTranspose( aTabla )[02]
         :aEditListBound := ArrTranspose( aTabla )[01]
         :bOnPostEdit:= { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oCol:value:= xVal, ;
                                                                        LoadItem( oBrw, xVal, aTabla ),;
                                                                        AddRow( oBrw ),;
                                                                        oBrw:SelectCol(01) ),) }
   END

   // Note: bOnPostEdit codeblocks are automatically constructed by SetArray() method

   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd

RETURN NIL

//------------------------------------------------------------------//

Static function AddRow( oBrw )
    LOCAL nn, xRet, lCont:= .f.
    LOCAL aStruct, uVal

   aStruct:= { 0, "", 0.00 }

   IF oBrw <> NIL
      xRet:= .t.
      IF oBrw:nLen > 0
         lCont:= !EMPTY(oBrw:aArrayData[oBrw:nLen,01])
      endif
      if oBrw:nLen == 0 .or. ;
          ( oBrw:nLen>0 .and. lCont )                                       // !EMPTY(oBrw:aArrayData[oBrw:nLen,nFldBlank]) )

         AAdd( oBrw:aArrayData, aStruct )

         oBrw:GoBottom()
         oBrw:Refresh()

      endif
      oBrw:SetFocus()
   endif

return xRet

//------------------------------------------------------------------//

STATIC FUNCTION LoadItem( oBrw, xVal, aTabla )
   Local xTmp, nn
   IF (nn:= ASCAN( aTabla, { |aItem| xVal == aItem[01] } )) > 0
      oBrw:aArrayData[oBrw:nArrayAt,01]:= aTabla[nn,01]
      oBrw:aArrayData[oBrw:nArrayAt,02]:= aTabla[nn,02]
      oBrw:aArrayData[oBrw:nArrayAt,03]:= aTabla[nn,03]
      oBrw:Refresh()
   endif
RETURN Nil

//------------------------------------------------------------------//




 
Ariel
 
Posts: 374
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: Error XBrowse edit_listbox

Postby nageswaragunupudi » Sat Oct 19, 2019 8:59 pm

Please try:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, aLin := {{0,"",0}}, i, oBrw, oBtn
   local aTabla:= { {  1, "item  1",  1.00 },;
                    {  2, "item  2",  2.00 },;
                    {  3, "item  3",  3.00 },;
                    {  4, "item  4",  4.00 },;
                    {  5, "item  5",  5.00 },;
                    {  6, "item  6",  6.00 },;
                    {  7, "item  7",  7.00 },;
                    {  8, "item  8",  8.00 },;
                    {  9, "item  9",  9.00 },;
                    { 10, "item 10", 10.00 } }

   DEFINE WINDOW oWnd

   @ 10,10 XBROWSE oBrw OF oWnd DATASOURCE aLin ;
      COLUMNS 1, 1, 3 ;
      HEADERS 'Cod', 'Description', 'Price' ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      WITH OBJECT :Description
         :nEditType     := EDIT_LISTBOX
         :aEditListTxt  := aTabla
         :bOnChange     := { || oBrw:aRow[ 3 ] := aTabla[ oBrw:aRow[ 1 ], 3 ], ;
                                oBrw:aRow[ 2 ] := aTabla[ oBrw:aRow[ 1 ], 2 ] }
      END
      :bPastEof   := <||
         if oBrw:nLen == 0 .or. !Empty( ATail( oBrw:aArrayData )[ 1 ] )
            AAdd( oBrw:aArrayData, { 0, "", 0 } )
            oBrw:GoDown()
            oBrw:Refresh()
         endif
         return nil
         >
      :CreateFromCode()
   END

   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd CENTERED

RETURN NIL
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error XBrowse edit_listbox

Postby Ariel » Sun Oct 20, 2019 1:30 pm

Mr.Rao,

gracias por contestar, evidentemente es una solución, pero es un parche, sigue sin funcionar correctamente, debería devolver el código, no la descripción, sino que sentido tiene la definición?
Saludos.
Ariel
 
Posts: 374
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: Error XBrowse edit_listbox

Postby nageswaragunupudi » Sun Oct 20, 2019 1:47 pm

Ariel wrote:Mr.Rao,

gracias por contestar, evidentemente es una solución, pero es un parche, sigue sin funcionar correctamente, debería devolver el código, no la descripción, sino que sentido tiene la definición?
Saludos.


I could not understand you clearly. Google translation is not clear.

Can you please explain once again?

Whatever be your problem, please let us know and we will provide a solution.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error XBrowse edit_listbox

Postby Ariel » Sun Oct 20, 2019 2:53 pm

Mr. Rao,

if i use:

:aEditListTxt := ArrTranspose( aTabla )[02] -> array char
:aEditListBound := ArrTranspose( aTabla )[01] -> array number

the logical thing would be for me to return a number, not characters
regards.
Ariel
 
Posts: 374
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: Error XBrowse edit_listbox

Postby nageswaragunupudi » Sun Oct 20, 2019 3:54 pm

Ariel wrote:Mr. Rao,

if i use:

:aEditListTxt := ArrTranspose( aTabla )[02] -> array char
:aEditListBound := ArrTranspose( aTabla )[01] -> array number

the logical thing would be for me to return a number, not characters
regards.


This is not necessary
if you use
:aEditListTxt := aTabla
That is more than enough.

Internally XBrowse derives aEditListBound, like this:
:aEditListTxt := ArrTranspose( aTabla )[02] -> array char
:aEditListBound := ArrTranspose( aTabla )[01] -> array number
Exactly the same thing you did in the program.
There is absolutely no difference.


This is the internal code in xbrowse.prg
Code: Select all  Expand view
  if ! Empty( ::aEditListTxt ) .and. Empty( ::aEditListBound ) .and. ;
      ValType( ::aEditListTxt[ 1 ] ) == 'A'
      // If multi-dim array 1st col as ListBound and 2nd col as ListTxt
      //
      ::aEditListBound     := ArrTranspose( ::aEditListTxt )
      ::aEditListTxt       := ::aEditListBound[ 2 ]
      ::aEditListBound     := ::aEditListBound[ 1 ]
      ::nDataStrAlign      := AL_LEFT
   endif
 


And Yes, it returns numbers, not strings as you wanted.

I am suggesting you the simpler way and recommended way to code for your requirements.

Kindly go through my sample again.

.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error XBrowse edit_listbox

Postby Marcelo Roggeri » Fri Oct 25, 2019 10:13 pm

Mr. Rao
Siguiendo el hilo, necesito saber si se puede buscar en un combo de estos, que estan dentro de un xBrowse.
Si pulso una letra y luego otra siempre se posiciona en la letra pulsada.
Espero haberme explicado y desde ya le agradezco su pronta respuesta.
Saludos
Marcelo
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 325
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: Error XBrowse edit_listbox

Postby cnavarro » Fri Oct 25, 2019 10:50 pm

Marcelo, quieres decir realizar una búsqueda incremental dentro del combo que se muestra en el xbrowse?
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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Error XBrowse edit_listbox

Postby Marcelo Roggeri » Sat Oct 26, 2019 12:32 am

Exacto Cristobal eso quiero si es que se puede
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 325
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: Error XBrowse edit_listbox

Postby cnavarro » Sat Oct 26, 2019 8:06 pm

Es que me parece que no es un combo, sino un listbox, pero no estoy seguro
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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Error XBrowse edit_listbox

Postby nageswaragunupudi » Sat Oct 26, 2019 11:20 pm

It is a listbox. Not combobox.

Incremental search is not supported now. We will endeavor to provide in future versions.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error XBrowse edit_listbox

Postby Marcelo Roggeri » Mon Oct 28, 2019 11:58 am

Mr. Rao
Es cierto me exprese mal es un listbox, al funcionar como un combo dentro del xBrowse, que bueno ojala sea posible para futuras versiones me parece muy útil.
Saludos
Marcelo
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 325
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Re: Error XBrowse edit_listbox

Postby nageswaragunupudi » Mon Oct 28, 2019 12:13 pm

Marcelo Roggeri wrote:Mr. Rao
Es cierto me exprese mal es un listbox, al funcionar como un combo dentro del xBrowse, que bueno ojala sea posible para futuras versiones me parece muy útil.
Saludos
Marcelo

We agree it is useful.
We will try to provide soon.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 99 guests