select options from sql source
select options from sql source
i want to add a select list to my editor, but the only values i want available are those which are not already in the target table.
eg.
SELECT ColourID AS Value, ColourDescription AS Label FROM refcolour
WHERE ColourID NOT IN (SELECT ColourID FROM tblproductcolour WHERE ProductID = ?)
is there a way to do this in version 1.6x without first creating a view ?
on earlier versions of editor I would create a select list separately in my ajax/json source and update the editor field on initComplete()
This question has accepted answers - jump to:
Answers
Yes .
You can use the
Options
class to do this:The documentation for the sub select is actually in the conditions part of the documentation.
The bit to fill out is the
:productId
binding value.Allan
...nearly there.
I got this to work when i set the bind value to an integer, but when i pass in a variable ($filter), which is the same variable used in the where clause, I get an error 'Notice: Undefined variable: ' on line 31 (line 16 in the snippet below)
..fixed it.
i created a second filter variable from the post value to use for the options
If you have a variable you want to use in an anonymous function in PHP you have to make use of the
use
keyword:Maddening syntax, but that's how PHP works.
Allan
Even better !
Cheers