I have a problem with a dependent dropdown, below is the code I use to generate inside the grid the 2 components. Whenever I edit a record, item is selected but the list is the list of all client not the list of this client only.
And if I add this : $col["editoptions"]["onload"]["sql"] = "SELECT asso.id as k, nom as v FROM appelservice INNER JOIN asso_clients_equipements asso ON asso.id=appelservice.fk_id_asso_client_equip INNER JOIN ref_equipements ref ON ref.id=asso.fk_id_equipement WHERE appelservice.fk_id_client = '{fk_id_client}'";
The list is good for the client but the item is not selected.
Below is the code of the 2 dropdown's.
$col = array();
$col["title"] = "Client";
$col["name"] = "fk_id_client";
$col["dbname"] = "clients.nomcomplet";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
$str = $g->get_dropdown_values("SELECT id as k, CONCAT(nomcomplet, '-', adresse) as v FROM clients ORDER BY nomcomplet");
$col["editoptions"] = array(
"value"=>$str,
"onchange" => array( "sql"=>"SELECT asso.id as k, nom as v FROM asso_clients_equipements asso INNER JOIN ref_equipements ref ON ref.id=asso.fk_id_equipement WHERE fk_id_client = '{fk_id_client}'",
"update_field" => "fk_id_asso_client_equip")
);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('{$col["name"]}'); },200); }";
$col["formatter"] = "select";
$cols[] = $col;
$col = array();
$col["title"] = "Équipements";
$col["name"] = "fk_id_asso_client_equip";
$col["search"] = false;
$col["editable"] = true;
$col["edittype"] = "select";
$str = $g->get_dropdown_values("SELECT asso.id as k, nom as v FROM appelservice INNER JOIN asso_clients_equipements asso ON asso.id=appelservice.fk_id_asso_client_equip INNER JOIN ref_equipements ref ON ref.id=asso.fk_id_equipement");
$col["editoptions"] = array("value"=>$str);
$col["formatter"] = "select";
$cols[] = $col;
thanks!
Hello,
I tested same scenario on demos/appearance/dropdown-dependent.php and unable to generate this issue.
Can you verify if this demo is working?
You can also send me grid code file and database sql dump to test here.
email me at [email protected]