Apply automatic filter to a dropdown list

QuestionsApply automatic filter to a dropdown list
Tony Wolsey asked 5 years ago

Hi Abu

I am sure there is an easy answer but the solution eludes me. How do I automatically¬†filter a dropdown list and limit the selection from within the PHP code. I have managed to set the correct default value but can’t filter away all the other selections in the dropdown list.¬† Basically, I want the selection to be automatically made and limited to only one selection option.


$col = array();
$col[“title”] = “ProjectNumber”;
$col[“name”] = “projectnumber”;
$col[“width”] = “100”;
$col[“editable”] = true;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
//$col[“frozen”] = true;
$col[“edittype”] = “lookup”;
$col[“editoptions”] = array(“defaultValue”=> PROJECT_NUMBER, “table”=>”tblprojectdetails”, “id”=>”projectnumber”, “label”=>”Projectnumber”);
$col[“editrules”] = array(“required”=>true); // and is required
////$col[“show”] = array(“edit”=>false); // only show freezed column in edit dialog
$cols[] = $col;


thanks you


1 Answers
Abu Ghufran Staff answered 5 years ago


Instead of providing table,id,label properties, you can replace it with:

$str = $g->get_dropdown_values(“select projectnumber as k, projectnumber as v from tblprojectdetails where projectnumber = “.PROJECT_NUMBER);

$col[“editoptions”] = array(“value”=>”:;”.$str);

OR if you don’t want to perform database query and hardcode one value only, you can do:

$col[“editoptions”] = array(“value”=>PROJECT_NUMBER.”:”.PROJECT_NUMBER);

Pasting from docs:

Render as select (dropdown), with these values “key:value;key:value;key:value”
$col[“edittype”] = “select”;
$col[“editoptions”] = array(“value”=>’10:$10;20:$20;30:$30;40:$40;50:$50′);

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Your Answer

18 + 5 =

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?