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.
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])