Page 1 of 1
Error XBrowse edit_listbox
Posted: Thu Oct 17, 2019 11:36 am
by Ariel
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
Re: Error XBrowse edit_listbox
Posted: Thu Oct 17, 2019 2:34 pm
by Ariel
El ejemplo :
Code: Select all
#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
//------------------------------------------------------------------//
Re: Error XBrowse edit_listbox
Posted: Sat Oct 19, 2019 8:59 pm
by nageswaragunupudi
Please try:
Code: Select all
#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

Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 1:30 pm
by Ariel
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.
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 1:47 pm
by nageswaragunupudi
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.
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 2:53 pm
by Ariel
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.
Re: Error XBrowse edit_listbox
Posted: Sun Oct 20, 2019 3:54 pm
by nageswaragunupudi
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
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.
.
Re: Error XBrowse edit_listbox
Posted: Fri Oct 25, 2019 10:13 pm
by Marcelo Roggeri
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
Re: Error XBrowse edit_listbox
Posted: Fri Oct 25, 2019 10:50 pm
by cnavarro
Marcelo, quieres decir realizar una búsqueda incremental dentro del combo que se muestra en el xbrowse?
Re: Error XBrowse edit_listbox
Posted: Sat Oct 26, 2019 12:32 am
by Marcelo Roggeri
Exacto Cristobal eso quiero si es que se puede
Re: Error XBrowse edit_listbox
Posted: Sat Oct 26, 2019 8:06 pm
by cnavarro
Es que me parece que no es un combo, sino un listbox, pero no estoy seguro
Re: Error XBrowse edit_listbox
Posted: Sat Oct 26, 2019 11:20 pm
by nageswaragunupudi
It is a listbox. Not combobox.
Incremental search is not supported now. We will endeavor to provide in future versions.
Re: Error XBrowse edit_listbox
Posted: Mon Oct 28, 2019 11:58 am
by Marcelo Roggeri
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
Re: Error XBrowse edit_listbox
Posted: Mon Oct 28, 2019 12:13 pm
by nageswaragunupudi
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.