Search inside Dropdown

QuestionsSearch inside Dropdown
Alfonso Cabrera asked 9 years ago

Hi Abu!

I want to be able to search inside the dropdown by name not by id.

I have this code.

$col = array();
$col["title"] = "Laboratorio"; // caption of column
$col["name"] = "idProveedores"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["editable"] = true;
$col["dbname"] = "proveedores.nombre"; //table that has the actual data.
$col["search"] = true;
$col["edittype"] = "select"; // render as select
$str = $g->get_dropdown_values("SELECT idProveedores as k, nombre as v FROM proveedores ORDER BY nombre");
$col["editoptions"] = array(
"value" => $str,
"onchange" => array("sql"=>"SELECT idProductos as k, nombre as v FROM productos WHERE idProveedores = {idProveedores} ORDER BY nombre",
"update_field" => "idProductos")
);
$col["formatter"] = "select"; // display label, not value
$cols[] = $col;

Table structure.

CREATE TABLE IF NOT EXISTS `portal`.`desplazamiento_medicina` (
`idDesplazamiento_Medicina` INT NOT NULL AUTO_INCREMENT,
`idProveedores` INT NULL,
`idProductos` INT NULL,
`num_licitacion` VARCHAR(45) NULL,
PRIMARY KEY (`idDesplazamiento_Medicina`))
ENGINE = InnoDB

CREATE TABLE IF NOT EXISTS `portal`.`proveedores` (
`idProveedores` INT NOT NULL AUTO_INCREMENT,
`nombre` VARCHAR(80) NULL,
PRIMARY KEY (`idProveedores`))
ENGINE = InnoDB

CREATE TABLE IF NOT EXISTS `portal`.`productos` (
`idProductos` INT NOT NULL AUTO_INCREMENT,
`idProveedor` INT NULL,
`nombre` VARCHAR(80) NULL,
PRIMARY KEY (`idProductos`))
ENGINE = InnoDB

If you need something else, tell me.

1 Answers
Abu Ghufran answered 9 years ago

The dbname 'proveedores.nombre' must be valid field when used in select_command.
$col["dbname"] = "proveedores.nombre";

Make sure you have proveedores table joined in query.

Please email complete code file if not resolved. ([email protected])

Your Answer

6 + 16 =

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?