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.
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.
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.
Code:
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 <5
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.
The documentation is using the sqlvalues built in function to create a list based on the query.
This is now working for me.
Code:
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.
Code:
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 <5
cellcombo.additems("one,two,three")
else
cellcombo.additems("Four,Five,Six")
endif
return mycontainer
endproc
All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers
Bookmarks