Dropdown autocomplete ID

QuestionsDropdown autocomplete ID
Alfonso Cabrera asked 9 years ago

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;

4 Answers
Abu Ghufran answered 9 years ago

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.

Alfonso Cabrera answered 9 years ago

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.

Abu Ghufran answered 9 years ago

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.

Alfonso Cabrera answered 9 years ago

Thanks Abu! You're the man!

Your Answer

1 + 4 =

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?