FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Error XBrowse edit_listbox
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Error XBrowse edit_listbox
Posted: 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

Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: Error XBrowse edit_listbox
Posted: Thu Oct 17, 2019 02:34 PM
El ejemplo :
Code (fw): Select all Collapse
#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

//------------------------------------------------------------------//
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error XBrowse edit_listbox
Posted: Sat Oct 19, 2019 08:59 PM
Please try:
Code (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 01: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.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 01: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
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 02:53 PM

Mr. Rao,

if i use:

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

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 03: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 (fw): Select all Collapse
   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
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: Error XBrowse edit_listbox
Posted: 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Error XBrowse edit_listbox
Posted: 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
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: Error XBrowse edit_listbox
Posted: Sat Oct 26, 2019 12:32 AM

Exacto Cristobal eso quiero si es que se puede

FWH - Harbour - BCC7 - PellesC
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Error XBrowse edit_listbox
Posted: Sat Oct 26, 2019 08: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error XBrowse edit_listbox
Posted: 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
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: Error XBrowse edit_listbox
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error XBrowse edit_listbox
Posted: 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

Continue the discussion