XBrowse with Multi-field as One-Row or Per-Row

XBrowse with Multi-field as One-Row or Per-Row

Postby fraxzi » Mon May 28, 2018 1:49 am

Hi Mr. Rao / All

Is this possible with xBrowse?

Image
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: XBrowse with Multi-field as One-Row or Per-Row

Postby nageswaragunupudi » Mon May 28, 2018 5:04 am

This can be done in different ways.
Here I suggest the simplest way:
Code: Select all  Expand view
function colsasrows()

   local oWnd, oBrw, oFont

   USE CUSTOMER
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   @ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "CUSTOMER" ;
      COLUMNS "FIRST","LAST","STREET","CITY","ZIP","HIREDATE","AGE","SALARY" ;
      HEADERS "CustName", nil, "Address", nil, nil, "Details" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :aCols[ 1 ]:SetColsAsRows( 1, 2 )
      :aCols[ 3 ]:SetColsAsRows( 3, 4, 5 )
      :aCols[ 6 ]:SetColsAsRows( 6, 7, 8 )
      //
      :CreateFromCode()
   END
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont

return nil

Image
Regards

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

Re: XBrowse with Multi-field as One-Row or Per-Row

Postby Silvio.Falconi » Mon May 28, 2018 8:42 am

Rao,
Can we add images on each lines?

sample :
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse with Multi-field as One-Row or Per-Row

Postby nageswaragunupudi » Mon May 28, 2018 8:48 am

yes
Regards

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

Re: XBrowse with Multi-field as One-Row or Per-Row

Postby nageswaragunupudi » Mon May 28, 2018 9:30 am

Another approach, a bit more complex:
Code: Select all  Expand view
function colsasrows()

   local oWnd, oBrw, oFont, aCols
   local nLine    := 0

   USE CUSTOMER ALIAS CUST
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   aCols := { ;
      { { || If( nLine == 0, STR(CUST->ID,4), "" ) }, "ID" }, ;
      { { || If( nLine == 0, CUST->FIRST, If( nLine == 1, CUST->LAST, "" ) ) }, "CustName" }, ;
      { { || If( nLine == 0, CUST->STREET, If( nLine == 1, CUST->CITY, CUST->ZIP ) ) }, "Address" }, ;
      { { || If( nLine == 0, DTOC(CUST->HIREDATE), If( nLine == 1, Str( CUST->AGE, 2 ), TRANSFORM( CUST->SALARY,"9,999,999.99") ) ) }, "Details" } }



   @ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "CUST" ;
      COLUMNS aCols ;
      CELL LINES NOBORDER

   // Navigation blocks
   oBrw:bGoTop    := { || nLine := 0, ( oBrw:cAlias )->( DBGOTOP()    ) }
   oBrw:bGoBottom := { || nLine := 2, ( oBrw:cAlias )->( DBGOBOTTOM() ) }
   oBrw:bKeyCount := { || ( oBrw:cAlias )->( OrdKeyCount() ) * 3 }
   oBrw:bKeyNo    := { || ( ( oBrw:cAlias )->( OrdKeyNo() - 1 ) * 3 ) + 1 + nLine  }
   oBrw:bSkip     := { |nSkip| ( oBrw:cAlias )->( MySkipper( nSkip, @nLine ) ) }
   oBrw:bKeyNo := { |n| If( n != nil, ( n--, ( oBrw:cAlias )->( OrdKeyGoTo( Int( n / 3 ) + 1 ) ), nLine := n % 3 ), nil ), ;
                        ( ( oBrw:cAlias )->( OrdKeyNo() - 1 ) * 3 ) + 1 + nLine }
   oBrw:bBookMark := { |n| If( n != nil, ( n--, ( oBrw:cAlias )->( DbGoTo( Int( n / 3 ) + 1 ) ), nLine := n % 3 ), nil ), ;
                        ( ( oBrw:cAlias )->( RecNo() - 1 ) * 3 ) + 1 + nLine }


   WITH OBJECT oBrw
      :aCols[ 1 ]:nDataStrAlign := AL_RIGHT
      :aCols[ 4 ]:nDataStrAlign := AL_RIGHT
      :aCols[ 4 ]:bLeftText   := { || If( nLine == 0, "Date:", If( nLine == 1, "Age:", "Sal:" ) ) }
      :aCols[ 4 ]:nWidth      := 140
      :bClrStd    := { || { CLR_BLACK, If( nLine == 0, CLR_HGRAY, CLR_WHITE ) } }
      //
      :CreateFromCode()
   END
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont

return nil

static function MySkipper( nSkip, nLine )

   local nSkipped := 0

   DEFAULT nSkip := 1

   if nSkip == 0
      return 0
   endif
   if nSkip > 0
      do while nSkipped < nSkip
         if nLine < 2
            nLine++
            nSkipped++
         else
            DBSKIP( 1 )
            if Eof()
               DBGOBOTTOM()
               EXIT
            endif
            nLine := 0
            nSkipped++
         endif
      enddo
   else
      do while nSkipped > nSkip
         if nLine > 0
            nLine--
            nSkipped--
         else
            DBSKIP( -1 )
            if BOF()
               EXIT
            endif
            nLine    := 2
            nSkipped--
         endif
      enddo
   endif

return nSkipped
 


Image
Regards

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

Re: XBrowse with Multi-field as One-Row or Per-Row

Postby Silvio.Falconi » Mon May 28, 2018 11:15 pm

nageswaragunupudi wrote:yes


How ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7057
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken and 114 guests