Hi Abu!
I have the following code:
$col = array();
$col["title"] = "Productos";
$col["name"] = "idProductos";
$col["dbname"] = "productos.idProductos"; // this is required as we need to search in name field, not id
$col["align"] = "left";
$col["width"] = 230;
$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 = $grid->get_dropdown_values("select idProductos as k, descripcion as v from productos");
$col["editoptions"] = array("value"=>$str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ link_select2('idProductos'); },200); }";
$cols[] = $col;
$grid->select_command = "SELECT idPrecios, productos.descripcion as idProductos, precio FROM precios INNER JOIN
productos on productos.idProductos = precios.idProductos WHERE idListas_Precios = $id";
The problem is when I use the autofilter, it searches by the ID of the table productos but I want to search by the description of the product. I enabled the dropdown search and it worked fine. I enabled the search inside dropdown feature as you can see in my code, I want the same but in the autofilter.
Hope you can help me out.
Thanks.
Just to clarify things. I want to search by the description of the product not using the dropdown feature.
Example:
Scr
The autofilter should give me the following result:
Screwdriver Green
Screwdriver Blue
Screwdriver Gray
….
I want a "contains" o "like" search. I don't know if the dropdown has a bad configuration or the search inside feature has something to do with the issue.
Working demo and code:
http://www.phpgrid.org/demo/demos/integrations/dropdown-select2.php
http://www.phpgrid.org/demo/demos/integrations/dropdown-select2.phps
Hi Abu!
I tried what you suggest but the problem is that if I want to search and list all the products that start with "scr" I need to check one by one to update additional information.
Can I use the autofilter not with a dropdown style but with a standard form?
I notice that if I let the default autofilter without the dropdown it searches by the ID and not by description.
Thank you.
Hello,
Ok, i understand now.
You can remove searchoptions settings, and it will become open textbox.
Next, you can set $col["dbname"] to your desired description field, and it will use it in WHERE clause.
$col["dbname"] = "table.field";
Make sure your table.field exist in select query field set.