xBrowse multi selects (resolvido)

xBrowse multi selects (resolvido)

Postby ip_ram » Tue Sep 18, 2018 3:49 pm

Olá!
Preciso selecionar várias linhas em um xBrowse (uso MySQL).
Vou mostrar uma lista de clientes e o usuário seleciona quais ele deseja.
Alguém indica um exemplo?
Obrigado!

Hello!
I need to select multiple rows in an xBrowse (MySQL usage).
I will show a list of clients and the user selects which ones he wants.
Does anyone indicate an example?
Thank you!

Rodrigo Melo
Belo Horizonte / MG
Brasil
Last edited by ip_ram on Tue Sep 25, 2018 8:09 pm, edited 1 time in total.
User avatar
ip_ram
 
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: xBrowse multi selects

Postby cnavarro » Tue Sep 18, 2018 4:05 pm

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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: xBrowse multi selects

Postby ip_ram » Tue Sep 18, 2018 4:36 pm

Navarro,

Gracias.
User avatar
ip_ram
 
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: xBrowse multi selects

Postby ip_ram » Sat Sep 22, 2018 11:06 pm

Navarro,

Após selecionar os registros no browse (oBrw) como recuperar os registros selecionados em aPes?

Code: Select all  Expand view  RUN

Function GrupoListarPessoa()

    Local oDlg, oBrw, oSay, oPar, oCon, oRet, lRet := .f.
   
    If ! Conectar(.f.)
        Return(Nil)
    EndIf
    oPar := oDba:RowSet("select id,nom_pes from tb_pes order by nom_pes",,.t.)
    If oPar == Nil
        Return(lRet)
    EndIf

    Define Dialog oDlg Title "Selecionar Participantes" Size 516,358 Of oWnd Pixel

    @ 28,2 xBrowse oBrw Of oDlg DataSource oPar ;
             Columns 'id','nom_pes' ;
             Headers 'ID','Pessoa' ;
             Pictures "999","@A" ;
             ColSizes 60,400 ;
             Font oFnt2 Size 255,150 Pixel UpDate Cell AutoSort

    oBrw:nMarqueeStyle    := 5
    oBrw:nDataType           := 64
    oBrw:nRowDividerStyle := 3
    oBrw:nColDividerStyle := 2

    With Object oBrw:InsCol(1)
        :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
        :SetCheck()
        :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
    End

    oBrw:bLClicked := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                   If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                     AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                     ADel( oBrw:aSelected, f, .t. ) ), Nil ), ;
                     oBrw:RefreshCurrent() }

    oBrw:aCols[1]:nHeadStrAlign := 2
    oBrw:aCols[2]:nHeadStrAlign := 2
    oBrw:aCols[3]:nHeadStrAlign := 0
    oBrw:aJustify                    := {2,1,0}

    oBrw:bOnRefresh := { || oSay:Refresh() }

    @ 8,05 Say 'Selecionados:' Of oDlg Pixel Font oFnt2
    @ 8,48 Say oSay Prompt Len(oBrw:aSelected) Size 12,12 Of oDlg Pixel Font oFnt2 Picture '99'

    @ 6,190 BTNBMP oCon Resource 'sel26' Of oDlg Size 32,16 Pixel 2007 ;
              Action(lRet:=.t.,oDlg:End()) ToolTip "Confirmar os selecionados"
    @ 6,226 BTNBMP oRet Resource 'sair16' Of oDlg Size 32,16 Pixel 2007 ;
              Action(lRet:=.f.,oDlg:End()) ToolTip "Retornar"

    oBrw:SetMySQL(oPar)
    oBrw:CreateFromCode()

    oDlg:oClient   := oBrw
    oDlg:lHelpIcon := .f.

    Activate Dialog oDlg Centered On Init oBrw:SetFocus()
 
    If lRet
        If Len(oBrw:aSelected) > 0
            aPes := oBrw:aSelected
        EndIf
    EndIf

Return(lRet)
 


Gracias

Rodrigo Melo
User avatar
ip_ram
 
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: xBrowse multi selects

Postby cnavarro » Sat Sep 22, 2018 11:21 pm

Rodrigo, intenta con oBrw:aSelected
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: xBrowse multi selects (resolvido)

Postby ip_ram » Tue Sep 25, 2018 1:17 am

Navarro,

Resolvido assim:

Code: Select all  Expand view  RUN

Function GrupoListarPessoa()

    Local oDlg, oBrw, oSay, oPar, oCon, oRet, lRet := .f.
   
    If ! Conectar(.f.)
        Return(Nil)
    EndIf
    oPar := oDba:RowSet("select id,nom_pes from tb_pes order by nom_pes",,.t.)
    If oPar == Nil
        Return(lRet)
    EndIf

    Define Dialog oDlg Title "Selecionar Participantes" Size 516,358 Of oWnd Pixel

    @ 28,2 xBrowse oBrw Of oDlg DataSource oPar ;
             Columns 'id','nom_pes' ;
             Headers 'ID','Pessoa' ;
             Pictures "999","@A" ;
             ColSizes 60,400 ;
             Font oFnt2 Size 255,150 Pixel UpDate Cell AutoSort

    oBrw:nMarqueeStyle    := 5
    oBrw:nDataType           := 64
    oBrw:nRowDividerStyle := 3
    oBrw:nColDividerStyle := 2

    With Object oBrw:InsCol(1)
        :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
        :SetCheck()
        :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
    End

    oBrw:bLClicked := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                   If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                     AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                     ADel( oBrw:aSelected, f, .t. ) ), Nil ), ;
                     oBrw:RefreshCurrent() }

    oBrw:aCols[1]:nHeadStrAlign := 2
    oBrw:aCols[2]:nHeadStrAlign := 2
    oBrw:aCols[3]:nHeadStrAlign := 0
    oBrw:aJustify                    := {2,1,0}

    oBrw:bOnRefresh := { || oSay:Refresh() }

    @ 8,05 Say 'Selecionados:' Of oDlg Pixel Font oFnt2
    @ 8,48 Say oSay Prompt Len(oBrw:aSelected) Size 12,12 Of oDlg Pixel Font oFnt2 Picture '99'

    @ 6,190 BTNBMP oCon Resource 'sel26' Of oDlg Size 32,16 Pixel 2007 ;
              Action(lRet:=.t.,aPes:=GrupoRecuperarPessoa(oBrw,oPar),oDlg:End()) ToolTip "Confirmar os selecionados"
    @ 6,226 BTNBMP oRet Resource 'sair16' Of oDlg Size 32,16 Pixel 2007 ;
              Action(lRet:=.f.,aPes:={},oDlg:End()) ToolTip "Retornar"

    oBrw:SetMySQL(oPar)
    oBrw:CreateFromCode()

    oDlg:oClient   := oBrw
    oDlg:lHelpIcon := .f.

    Activate Dialog oDlg Centered On Init oBrw:SetFocus()

Return(lRet)

Function GrupoRecuperarPessoa(oBrw,oPar)

    Local aVet := {}, nCtr := 0

    If Len(oBrw:aSelected) > 0
        For nCtr := 1 To Len(oBrw:aSelected)
            oPar:GoTo(oBrw:aSelected[nCtr])
            AAdd(aVet,oPar:Id)
        Next
    EndIf

Return(aVet)
 


Agradecimento ao JMSilva (silva.ifsp@gmail.com).

Um abraço!

Rodrigo Melo
User avatar
ip_ram
 
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: xBrowse multi selects (resolvido)

Postby nageswaragunupudi » Tue Sep 25, 2018 11:25 pm

oBrw:nDataType := 64

This is wrong.
Correct nDataType is DATATYPE_ODBF (16)

XBrowse automatically decides the correct datatype, when you create the browse based on the type of DATASOURCE.
Not only that you do not have to assign the value yourself, but it is also highly undesirable as in the above case.
Regards

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

Re: xBrowse multi selects (resolvido)

Postby ip_ram » Wed Sep 26, 2018 1:16 am

Rao,

Tks.
User avatar
ip_ram
 
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests