xsharp.eu • Field grouping in bBrowser
Page 1 of 1

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 6:56 am
by Anonymous
I'm trying to combine CLADD1 and CLADD2 into a two line column, using the bBrowser help file entry here:

My Code:

method PostInit(oWindow,iCtlID,oServer,uExtra) class AddBookList
//Put your PostInit additions here
LOCAL oColumn as bDataColumn
Local oBrowser as bBrowser
oBrowser := self:oDCbBrowser1
oServer := self:oDCbBrowser1:Server
oColumn := bDataColumn{oBrowser, oServer, {|Server| Server:CLADD1+CRLF+Server:CLADD2}, #Expression}
oColumn:Width := 350
self:oDCbBrowser1:AddColumn(oColumn)
self:oDCbBrowser1:Refresh()
self:oDCbBrowser1:Recalculate()
Return nil



bBrowser 4 Help File
In the following sample a data column is created on an expression. The expression adds the 2 fields FIRSTNAME and LASTNAME from a DBServer (CUSTOMER.DBF) to a double line value.



LOCAL odbsCUSTOMER AS DBServer

LOCAL oBrowser AS bBrowser

LOCAL oColumn AS bDataColumn



// Create DBServer

odbsCUSTOMER := DBServer{"CUSTOMER"}



// Create browser

oBrowser := bBrowser{oOwner,;

1000,;

Point{0, 0},;

Dimension{300, 250}}



// Set the DBServer in browser and show the browser

// -> The empty array results in no data columns

// being created automatically.

oBrowser:Use(odbsCUSTOMER, {})

oBrowser:Show()



// Enable the variable row height so that the

// column values are displayed in 2 lines.

oBrowser:EnableRowHeightVariable(TRUE)



// Create a data column for the fields FIRSTNAME and LASTNAME

oColumn := bDataColumn{oBrowser,;

odbsCUSTOMER,;

"Server:FIRSTNAME" + CRLF + "Server:LASTNAME",;

#EXPRESSION}

oColumn:Hyperlabel := HyperLabel{#MYCOLUMN}



// Add data column to browser and open it

oBrowser:AddColumn(oColumn)

oBrowser:OpenColumn()



It does not work. Nothing happens... What am I doing wrong please?

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 6:58 am
by wriedmann
Hi Jeff,
create an access in your DBServer class and use it in the bBrowser column.
Wolfgang

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 7:10 am
by BiggyRat
Hmm ok. Thank you once again Wolfgang

I couldn't get that to work. Nothing changed at all. Is tge order ive done everything correct?

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 4:46 pm
by g.bunzel@domonet.de
Jeff,

...maybe you see only the first line of your two line field?

This line is not in your code:

// Enable the variable row height so that the
// column values are displayed in 2 lines.
oBrowser:EnableRowHeightVariable(TRUE)


HTH

Gerhard Bunzel

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 4:58 pm
by Karl-Heinz
Hi Jeff,

I´m using a expression Datacolumn in a different way. Using a callback method gives you much more flexibility to control the cell content. BTW. if CRLFs are used you must ensure that the Valtype of the column is always "M".

Just add this code to your app and give it a try.

Code: Select all

method PostInit(oWindow,iCtlID,oServer,uExtra) class AddBookList

oBrowser:EnableRowHeightVariable(TRUE) 
...
oColumn := bDataColumn{ oBrowser, oServer, { | oDB, oOwner| oOwner:FillColumnCladd ( oDB) }, #Expression , self }
oColumn :ValType := "M"	
...


METHOD FillColumnCladd ( oServer ) CLASS AddBookList

 	RETURN oServer:Fieldget ( #CLADD1 ) + CRLF + oServer:Fieldget ( #CLADD2 ) 

regards
Karl-Heinz

Field grouping in bBrowser

Posted: Wed Nov 20, 2019 10:23 pm
by BiggyRat
Sorry Karl-Heinz:

This code:

method PostInit(oWindow,iCtlID,oServer,uExtra) class AddBookList
//Put your PostInit additions here
LOCAL oColumn as bDataColumn
Local oBrowser as bBrowser
oBrowser := self:oDCbBrowser1
oServer := self:oDCbBrowser1:Server
oBrowser:EnableRowHeightVariable(true)
oBrowser:Use(oServer, {#CLADD1, #CLADD2})
oColumn := bDataColumn{ oBrowser, oServer, { | oServer, oBrowser| oBrowser:FillColumnCladd ( oServer) }, #Expression , self }
oColumn :ValType := "M"
oBrowser:AddColumn(oColumn)
oBrowser:Refresh()
oBrowser:Recalculate()
Return nil

METHOD FillColumnCladd ( oServer ) CLASS AddBookList

RETURN oServer:Fieldget ( #CLADD1 ) + CRLF + oServer:Fieldget ( #CLADD2 )


Still returns:
Capture.JPG
Capture.JPG (13.34 KiB) Viewed 599 times
Jeff

Field grouping in bBrowser

Posted: Thu Nov 21, 2019 6:03 am
by Karl-Heinz
Hi Jeff,

The quality of the attached image is poor, but that´s another story <sigh> ...

https://www.xsharp.eu/forum/suggestions ... s-to-a-msg

I "see" two columns, but the 3th column that should show the content of #CLADD1 *and* #CLADD2 is not visible because you do not open the created column. Note: In addition i added a Hyperlabel.

Code: Select all

...  
oColumn := bDataColumn{ oBrowser, oServer, { | oDB, oOwner| oOwner:FillColumnCladd ( oDB) }, #Expression , self }
oColumn:ValType := "M"	
oColumn:Width := 200
oColumn:HyperLabel := HyperLabel{#USERCLADD,"USERCLADD",NULL_STRING,NULL_STRING}
oColumn:Caption := "Jeffs special Col"
oBrowser:addcolumn ( oColumn )
oBrowser:OpenColumn ( oColumn )  // <--------------
...
regards
Karl-Heinz

Field grouping in bBrowser

Posted: Thu Nov 21, 2019 9:15 am
by BiggyRat
Thanks so much Karl-Heinz! I had put the OpenColumn in in past attempts, but obviously not all together. Thank you very much again Karl-Heinz and Wolfgang. Here's what I wanted to achieve, and thanks to you guys, I now have:

New Column.JPG
New Column.JPG (19.48 KiB) Viewed 599 times