Choice

You can specify a SQL SELECT statement in the choices attribute.
+select companyname from customers
Put a + at the start of the statement will add a blank entry to the list.

Q:
The choiceList (‘Choices’) attribute for fields and grid columns can now be specified as a macro expression “{myproc(‘arg’,…}” that will be expanded in desktop, web and mobile.
It looks to me like the choices field is picking up the value as a literal (unless I am doing it wrong) and not running the macro.
I’ll wait for Yvonne or Barry to chime in.You can always use a custom control though.
For example, here is a custom control that conditionally lists the drop down choices based on employeeid.
customchoice1.jpg
The code is here –
I just create a container, add a readonly textbox and a combobox.
You can see the conditional logic in the proc.

proc customChoices(empid)

mycontainer = createObject("container")
mycontainer.layout = 1
mycontainer.autosize = 1
mycontainer.backcolor = "blue"
mycontainer.addobject("mytext","textbox")
mycontainer.addobject("cellcombo","combobox")
mytext.value = extension
mytext.readonly=.t.
if empid 
cellcombo.additems("one,two,three")
else
cellcombo.additems("Four,Five,Six")
endif

return mycontainer 
endproc
Also in my app, if I put some function in the “choice” delegate, Lianja return the name of the function..
A:
This is what you will see if you have an error in your dynamicchoice proc/func.
I am guessing you were making the same mistake I made with the choice list.
It has to return a comma seperated list.Looking at the example Yvonne pointed to, the documentation is using the sqlvalues built in function to create a list based on the query.This is now working for me.

proc dynamicchoice()

sqlvalues("select postalcode from employees")
myvals = astring(_sqlvalues)
return myvals
endproc

As with any custom section, you create your controls in classes, then use them.

In this example, I first subclass combobox as fabiocombo and add the valid event as a proc.

define class fabiocombo as combobox

proc valid()
Lianja.showMessage("Valid was fired")
endproc

enddefine

proc customChoices(empid)

mycontainer = createObject("container")
mycontainer.layout = 1
mycontainer.autosize = 1
mycontainer.backcolor = "blue"
mycontainer.addobject("mytext","textbox")
mycontainer.addobject("cellcombo","fabiocombo")
mytext.value = extension
mytext.readonly=.t.
if empid 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s