I cannot get a dropdown to filter correctly in an add dialog.

QuestionsI cannot get a dropdown to filter correctly in an add dialog.
Tim Moore asked 1 year ago

The code below does not seem to filter the site names by customer_id. It still shows all sites names, i am not sure what i am doing wrong here.

 // CUSTOMER SITE
$col = array();
$col[“title”] = “Site Name”;
$col[“name”] = “site_name”;
$col[“dbname”] = “store.customer_site_id”;
$str = $g->get_dropdown_values(“SELECT *, site_name as v, customer_site_id as k FROM tbl_customer_sites”);
$col[“width”] = “55”;
$col[“hidden”] = true;
$col[“editable”] = true;
$col[“stype”] = “select”;
$col[“edittype”] = “select”;
$col[“show”] = array(“list”=>true, “add”=>true, “edit”=>true, “view”=>false, “bulkedit”=>false);
$col[“editoptions”] = array(“value” => “:;” . $str);

$col[“editoptions”][“dataInit”][“sql”] = “SELECT customer_site_id AS k, site_name AS v FROM tbl_customer_sites WHERE sites_fk_customer_id IN ({customer_id})”;

$col[“export”] = false;
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;

Thanks in advanced.
Tim

4 Answers
Aby answered 1 year ago

Please share complete code for review including select command query.

If you are using OR condition in query, make sure you enclose it in ( ) so it may not combine with other AND conditions.

Tim Moore answered 1 year ago

https://gist.github.com/tmoore88/a5268f5e3429334d177a19af371b2574

The code above is the complete code

 

Thanks,

Tim

Tim Moore answered 1 year ago

This is still an issue, and i am not sure what i am doing wrong?

Abu answered 11 months ago

Replied on your direct email.


I was little occupied in other cases so this ticket was missed.

After reviewing your code, I can see there is no table ‘store’ in your select_command so most like this query is failing due to this.
$col[“dbname”] = “store.customer_site_id”;

Try changing it to:

$col[“dbname”] = “customer_site_id”;

You can also set:

$g->debug_search = true;

And this will show the complete select query in debug box for review.

Your Answer

20 + 12 =

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?