Xbrowse multiple selection for showing colum names

Xbrowse multiple selection for showing colum names

Postby Marc Venken » Thu May 11, 2017 9:32 pm

Hello Mr. Rao,

Maybe It can be possible in the near future that the selection of colums we want to see can be selected in 1 go?

As far as I can test, we need to select again for every column. (Right click headers, select and again ,....)

Purpose : I have all fields in the browse, but for report/exell I select only the fields I want, so unselecting what is not needed.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Xbrowse multiple selection for showing colum names

Postby nageswaragunupudi » Wed May 17, 2017 5:57 am

Code: Select all  Expand view
function XbrColSelector( oBrowse )

   local oDlg, oBrw
   local aSave    := aCopy( oBrowse:aCols )

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "lHide", "cHeader" ;
      HEADERS "", "Header" ;
      COLSIZES 40, 100 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      WITH OBJECT :aCols[ 1 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .t. )
         :nHeadBmpNo    := 2
      END
      :CreateFromCode()
   END

   @ 20,180 BTNBMP PROMPT "Close" SIZE 100,30 FLAT PIXEL OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   oBrowse:Refresh()

return nil

//----------------------------------------------------------------------------//
 


Keep this function in your program.

When you define a browse, add this line
Code: Select all  Expand view
  oBrw:bRClickHeaders := { || XbrColSelector( oBrw ) }
 

You can check on and off the columns to hide.
With Ctrl_Uparrow and ctrl-downarrow you can change the order of the columns
Regards

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

Re: Xbrowse multiple selection for showing colum names

Postby ukoenig » Wed May 17, 2017 6:35 am

I added this solution to the sample-collector.
It saves a lot of time ( just 5 minutes ) because no defines of windows, dialogs or folders is needed.
Just include the code to any of the group-sections of window, dialog or folder.
I counted round about > 100 tests could be added.

Image

Code: Select all  Expand view


// -------------------------------------------------------------------- SECTION 1 Page 1 - 4

FUNCTION SS1_PART1( oFld1, nSavePage ) // 1. Page and 2. sample
LOCAL aBitmaps1
...
...
// ------------------- 2. sample

@ 155,10 XBROWSE oBrw[2] OF oFld1:aDialogs[1] ;
      SIZE -10, 123 PIXEL ;
      COLUMNS 'FIRST', "LAST", 'HIREDATE', 'MARRIED', 'SALARY' ;
      ALIAS 'CUST' LINES NOBORDER AUTOSORT FONT oFont

oBrw[2]:Married:SetCheck()  // Default FWH Bitmap is Alpha

WITH OBJECT oBrw[2]
    :bRClickHeaders := { || XBRCOLSELECTOR( oBrw[2] ) } // added !!!!
    :nStretchCol    := 1
    :nMarqueeStyle := 4
    :lHScroll       := .F.
    :bClrStd        := { || If( oBrw[2]:KeyNo() % 2 == 0, ;
                { If( ( oBrw[2]:cAlias )->( Deleted() ), 255, CLR_BLACK ), nRGB( 181, 255, 218 ) }, ;
                { If( ( oBrw[2]:cAlias )->( Deleted() ), 255, CLR_BLACK ), nRGB( 175, 255, 255 ) } ) }
    :bClrSel        :=  ;
    :bClrSelFocus   := { || { If( ( oBrw[2]:cAlias )->( Deleted() ), 255, CLR_BLACK ), RGB( 255, 233, 162 ) } }
    :lFooter        := .T.
    :AutoFit()

    WITH OBJECT :First
        :AddBitmap( c_Path1 + 'open2.bmp' ) // non-alpha bitmap
        :AddBmpFile( c_Path1 + "Sort.bmp" )
        :bBmpData   := { || 1 }
        :nHeadBmpNo   := 2
    END

    WITH OBJECT :Last
        :AddBmpFile( c_Path1 + "Sort.bmp" )
        :nHeadBmpNo   := 1
    END

    WITH OBJECT :HireDate
        :AddBitmap( c_Path1 + 'task.bmp' )  // alpha
        :AddBmpFile( c_Path1 + "Sort.bmp" )
        :bBmpData   := { || 1 }
        :nHeadBmpNo   := 2
    END

    WITH OBJECT :Married
        :AddBmpFile( c_Path1 + "Sort.bmp" )
        :nHeadBmpNo   := 1
    END

    WITH OBJECT :Salary
        :AddBmpFile( c_Path1 + "Sort.bmp" )
        :nHeadBmpNo   := 1
    END
END

oBrw[2]:aCols[ 2 ]:bClrStd := {|| { CLR_HRED, 14540253 } }    

oBrw[2]:CreateFromCode()

@ 280,20 SAY oBrw[2]:oSeek PROMPT oBrw[2]:cSeek SIZE 50,10 PIXEL BORDER ;
OF oFld1:aDialogs[1] COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'

RETURN NIL
 


regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 121 guests