Include WHERE with get_dropdown_values

QuestionsInclude WHERE with get_dropdown_values
dai asked 6 years ago

For get_dropdown_values, Is it possible to grab a value from the current row but a different column and implement WHERE to filter the possible values?
 
Example:
TABLE #1: task
Column:  name, project_id, milestone_id
Data: my task, 3, 7
 
Table #2: milestone
Column: id, name, project_id
Data: 7, planning, 3
Data: 8, maintain, 4
Data: 9, evaluate, 3
 
When editing the row from Task, have a drop down for the milestone column to use the value “3” from the column “project_id”.

$str = $g->get_dropdown_values("select distinct id as k, name as v from milestone WHERE {project_id} ");

Which would execute: select distinct id as k, name as v from milestone WHERE project_id=3
And pull down to generate the value “planning” and “evaluate”

1 Answers
Abu Ghufran Staff answered 6 years ago

With that dropdown, you need to have following code:
$str = $g->get_dropdown_values("select distinct id as k, name as v from milestone");
$col[“editoptions”] = array(“value”=>$str);
$col[“editoptions”][“onload”][“sql”] = “select distinct id as k, name as v from milestone WHERE project_id = {project_id}“;
Removed where condition from get_dropdown() and added “onload-sql” option.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

7 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?