| Subject |
Re: representation of logical field |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Thu, 21 Jul 2022 15:32:27 +0200 |
| Newsgroups |
dbase.getting-started |
| Attachment(s) |
morph_logical.wfm |
On 2022/07/21 11:31, Mustansir Ghor wrote:
> Dear All
>
> I am displaying a logical in the grid. I with to display true as blocked and false as unblocked.
> Is this possible to do it?
If you are using .dbf files and you want to display the words "Blocked"
and "Unblocked" in the grid instead of a ticked or unticked checkbox you
just need to add a calculated field to your rowset.
A little example is attached.
If your tables are on a SQL server you can use a CASE statement in the
query's SELECT statement to morph the boolean value to text.
Unfortunately the limitations of localSQL prevent this solution where
.dbf files are used.
In a report you can simply use the canRender event handler of the text
object that displays the logical field to substitute "Blocked" and
"Unblocked" for true or false.
Mervyn.
|
if file('morph_logical.dbf')
drop table morph_logical
endif
if not file('morph_logical.dbf')
create table morph_logical (id autoinc,data character(15),logical_fld boolean)
use morph_logical
generate 10
use
endif
** END HEADER -- do not remove this line
//
// Generated on 2022-07-21
//
parameter bModal
local f
f = new morph_logicalForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class morph_logicalForm of FORM
with (this)
height = 17.7727
left = 52.0
top = 0.2273
width = 96.0
text = ""
endwith
this.MORPH_LOGICAL1 = new QUERY(this)
with (this.MORPH_LOGICAL1)
onOpen = class::MORPH_LOGICAL1_ONOPEN
left = 6.0
top = 1.0
width = 12.0
height = 1.0
sql = 'select * from "morph_logical.DBF"'
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.morph_logical1.rowset
height = 12.1818
left = 3.8571
top = 2.6818
width = 81.1429
endwith
this.rowset = this.morph_logical1.rowset
function MORPH_LOGICAL1_onOpen()
f = new Field()
f.fieldName = 'morph_logic'
f.beforeGetValue = {||iif( this.parent["logical_fld"].value= true,"Blocked","Unblocked")}
this.rowset.fields.add( f )
return
endclass
|