2 grid columns, each with a separate dropdown

Questions2 grid columns, each with a separate dropdown
Grant Bristow asked 7 years ago

I have a grid with 2 lookup columns. As far as I can tell, they are identically coded (with consideration that they lookup on different tables). There is 1 column in between the two. Here is my php code. The second grid column with a dropdown (PO_status) works. The first column, Status, does not.

$col = array();
$col["name"] = "Status";
$col["editable"] = true;
$col["width"] = "80";
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$req_str = $g->get_dropdown_values("select distinct req_status as k, req_status as v from req_status");
$col["editoptions"] = array(
"value"=>$req_str,
"onchange" => array(
"sql"=>"select * from req_status",
"search_on"=>"req_status",
"callback" => "fill_form" )
);

$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["status"]}'); },200); }";

$col["stype"] = "select"; // enable dropdown search
$col["searchoptions"] = array("value" => ":;".$req_str);
$cols[] = $col;

$col = array();
$col["name"] = "PO_number";
$cols[] = $col;

$col = array();
$col["name"] = "PO_status";
$col["editable"] = true;
$col["width"] = "80";
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$po_str = $g->get_dropdown_values("select distinct po_status as k, po_status as v from po_status");
$col["editoptions"] = array(
"value"=>$po_str,
"onchange" => array(
"sql"=>"select * from po_status",
"search_on"=>"po_status",
"callback" => "fill_form" )
);

$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["PO_status"]}'); },200); }";

$col["stype"] = "select"; // enable dropdown search
$col["searchoptions"] = array("value" => ":;".$po_str);
$cols[] = $col;

3 Answers
Abu Ghufran answered 7 years ago

In both cases,
change param of link_select2 to $col["name"]
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["name"]}'); },200); }";

Rest code looks fine. If you can send screenshot of issue, it would help.

Bruce Grant answered 7 years ago

Thank you, Abu, for the speedy answer. I changed the link_select2 line to use $col["name"] but I still get the same problem. Here is a screenshot. As you can see, the "PO Status" shows the dropdown, but the Status neither shows nor performs the dropdown.

(I can't see how to attach a screenshot, so I have emailed you at [email protected] with it attached.)

Abu Ghufran answered 7 years ago

To show select2 while editing:
$col["edittype"] = "select";
$col["editoptions"] = array("value"=>$str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["name"]}'); },200); }";

To show select2 in autofilter search:
$col["stype"] = "select";
$col["searchoptions"] = array("value"=>$str);
$col["searchoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('gs_{$col["name"]}'); },200); }";

you need to replace $str with your values / variable.

Your Answer

12 + 2 =

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?