Issue with Autofilter

QuestionsIssue with Autofilter
Alfonso Cabrera asked 8 years ago

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.

4 Answers
Alfonso Cabrera answered 8 years ago

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.

Alfonso Cabrera answered 8 years ago

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.

Abu Ghufran answered 8 years ago

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.

Your Answer

4 + 9 =

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?