Hi Abu!
How can I get the id value of the dropdown autocomplete?
Here is my code:
$col = array();
$col["title"] = "Clientes";
$col["name"] = "idClientes";
$col["dbname"] = "clientes.idClientes"; // this is required as we need to search in name field, not id
$col["align"] = "left";
$col["width"] = 250;
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select idClientes as k, nombre as v from clientes");
$col["editoptions"] = array("value"=>$str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('idClientes'); },200); }";
$col["stype"] = "select"; // render as select
$col["searchoptions"] = array("value"=>$str);
$col["searchoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('gs_idClientes'); },200); }";
$cols[] = $col;
The id of the dropdown is posted back to server on submit.
If you want dropdown id value in JS, you can inspect the html select using firebug and read value using Jquery.
Hi Abu!
I´m using the master-detail grid. I passed the following parameters to my [on_insert] and [on_update] function inside the detail grid.
$id = intval($_GET["rowid"]);
$client = intval($_GET["idClientes"]);
The problem is that I recieve the Name of the client insted of the ID. I didn't mention that I use the master-detail. So when I get the ID of the master record selected but not the ID of the client. Above you can see that I use the autocomplete dropdown.
In select_command you must select the ID (not label) to show in grid.
Use get_dropdown_values to load values
and use $col["formatter"] = "select" in column setting to show label instead of id
After using these settings, the id will be passed instead of label.