FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour build xbrowse to Rao
Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
build xbrowse to Rao
Posted: Mon Mar 09, 2015 03:55 PM
Buen dia,

Estoy tratando de construir un xbrowse con datos en arreglos para hacer una funcion universal de xbrowse, pero no me muestra los datos, que hago mal?

aqui la imagen


adjunto codigo:

Code (fw): Select all Collapse
    ::aHeaders := { "Codigo", "Nombre", "Abreviado", "Permisos" }
    ::aFields := { "id", "nombre", "iniciales", "permiso" }
    ::aPictures := { "9999",,, }
    ::aDatas := { { AL_CENTER, AL_RIGHT,  060 },;
                        { AL_CENTER, AL_LEFT,   400 },;
                        { AL_CENTER, AL_LEFT,   050 },;
                        { AL_CENTER, AL_CENTER, 030 } }

  ::oQry := oServer:Query("SELECT * FROM usuarios")

   DEFINE WINDOW ::oWndChild MDICHILD OF oApp:oWnd
   @ 0,0 XBROWSE ::oBrw OF ::oWndChild

   ::oBrw:SetMySQL( ::oQry, .F. )
   ::oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLROW
   ::oBrw:nColDividerStyle    := LINESTYLE_LIGHTGRAY
   ::oBrw:nRowDividerStyle    := LINESTYLE_LIGHTGRAY
   ::oBrw:lColDividerComplete := .T.
   ::oBrw:nHeaderHeight       := 28
   ::oBrw:nRowHeight          := 20
   ::oBrw:lAllowColHiding     := .F.
   ::oBrw:lAllowRowSizing     := .F.
   ::oBrw:lAllowColSwapping   := .F.
   ::oBrw:nStretchCol         := STRETCHCOL_LAST
   ::oBrw:nRecSelColor        := nRGB( 240, 240, 240 )
   ::oBrw:bClrStd             := {|| if( ::oQry:RecNo()%2 == 0, { CLR_BLACK, CLR_WHITE }, { CLR_BLACK, nRGB( 218, 250, 216 ) } ) }
   ::oBrw:bClrSelFocus        := { || { CLR_WHITE, nRGB(0,128,192) } }
   ::oBrw:bClrHeader          := {|| { nRGB(0,0,0), nRGB( 240, 240, 240 ) } }
   ::oBrw:bClrGrad            := { || { { 0.80, nRGB( 240, 240, 240 ), nRGB( 215, 215, 215 ) }, ;
                                        { 0.20, nRGB( 211, 211, 209 ), nRGB( 240, 240, 240 ) } } }

   FOR x := 1 TO LEN( ::aFields )
      cField := ::aFields[x]
      WITH OBJECT aoCols[x] := ::oBrw:AddCol()
         :cHeader       := ::aHeaders[x]
         IF ::oQry:FieldType( ::oQry:FieldPos( cField ) ) == "N"
            :bEditValue    := { || ::oQry:FieldGet( cField ) }
            :cEditPicture  := ::aPictures[x]
         ELSE
            :bStrData      := { || ::oQry:FieldGet( cField ) }
         ENDIF
         :nHeadStrAlign := ::aDatas[x,1]
         :nDataStrAlign := ::aDatas[x,2]
         :nWidth        := ::aDatas[x,3]
      END WITH
   NEXT

   ::oBrw:CreateFromCode()

   AEval( ::oBrw:aCols, { |o| o:lAllowSizing := .f. } )

   ACTIVATE WINDOW ::oWndChild
____________________

Paco
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: build xbrowse to Rao
Posted: Wed Mar 11, 2015 05:05 PM
Above code re-written
Code (fw): Select all Collapse
   ::oQry := oServer:Query("SELECT * FROM usuarios")

   // Prepare a multi-dim array with columns as
   // EXPRESSION, HEADER, PICTURE, COLSIZE, ALIGN, SORT
   // First column is essential. All Other columns are optional
   
  aCols := { ;
   { "id",        "Codigo",    "9999",  60, AL_RIGHT,   nil   }, ;
   { "Nombre",    nil,         nil,    400                    }, ;
   { "iniciales", "Abreviado", nil,     50                    }, ;
   { "Permiso",   "Permisos",  nil,     30                    }  }
   
    
   DEFINE WINDOW ::oWndChild MDICHILD OF oApp:oWnd
   @ 0,0 XBROWSE ::oBrw OF ::oWndChild DATASOURCE ::oQry ;
      COLUMNS aCols LINES NOBORDER

   WITH OBJECT ::oBrw
      :nHeadStrAligns      := AL_CENTER
      :lAllowSizings       := .f.
      :nMarqueeStyle       := MARQSTYLE_HIGHLROW
      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
      :lColDividerComplete := .T.
      :nHeaderHeight       := 28
      :nRowHeight          := 20
      :lAllowColHiding     := .F.
      :lAllowRowSizing     := .F.
      :lAllowColSwapping   := .F.
      :nStretchCol         := STRETCHCOL_LAST
      :nRecSelColor        := nRGB( 240, 240, 240 )
      :bClrStd             := {|| if( ::oQry:RecNo()%2 == 0, { CLR_BLACK, CLR_WHITE }, { CLR_BLACK, nRGB( 218, 250, 216 ) } ) }
      :bClrSelFocus        := { || { CLR_WHITE, nRGB(0,128,192) } }
      :bClrHeader          := {|| { nRGB(0,0,0), nRGB( 240, 240, 240 ) } }
      :bClrGrad            := { || { { 0.80, nRGB( 240, 240, 240 ), nRGB( 215, 215, 215 ) }, ;
                                           { 0.20, nRGB( 211, 211, 209 ), nRGB( 240, 240, 240 ) } } }
      //
      :CreateFromCode()
   END
   oWnd:SetControl( ::oBrw )

   ACTIVATE WINDOW ::oWndChild
Regards



G. N. Rao.

Hyderabad, India
Posts: 845
Joined: Sun Oct 09, 2005 05:36 PM
Re: build xbrowse to Rao
Posted: Thu Mar 12, 2015 04:53 PM

Bien !!

Gracias Rao
Saludos
Paco

____________________

Paco

Continue the discussion