Auto Lookup show only exact match

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
elemire
Posts: 8
Joined: 2015-09-11 18:17

Auto Lookup show only exact match

Post by elemire » 2015-09-11 18:22

Hi Guys,

Been using Appgini for several months now to try and create an inventory management program for my company. Everything is coming along good however I am running into one problem I cant figure out how to solve. We have an autolookup filed and when the user scans a barcode into that field it pulls back the information on the skid, such as product number and case count.

Where I am having a problem is if I have a barcode with the value 10 and one entered with the value 100, when they scan barcode 10 it also pulls back 100 in the drop down menu. Is there any way for me to limit the auto lookup to exact matches only. If they scan barcode 10 I don't want it to pull back 10, 100 and 1000 as well.

User avatar
a.gneady
Site Admin
Posts: 1354
Joined: 2012-09-27 14:46
Contact:

Re: Auto Lookup show only exact match

Post by a.gneady » 2015-09-13 19:01

Do you have other lookup fields in your application? If not, this would do the trick: Open the generated "ajax_combo.php" in a text editor and find this line:

Code: Select all

$wheres[] = "{$field['parent_caption']} like '%{$search_term}%'";
and modify it to:

Code: Select all

$wheres[] = "{$field['parent_caption']}='{$search_term}'";
Beware that if you have other lookup fields, the above would cause them to return exact matches only.
:idea: AppGini plugins to add more power to your apps:

elemire
Posts: 8
Joined: 2015-09-11 18:17

Re: Auto Lookup show only exact match

Post by elemire » 2015-09-14 13:27

Thanks for the code it worked perfectly! And the fast response is much appreciated, is it possible to change the code to have the quick search filed at the top act the same way, return only exact matches?

elemire
Posts: 8
Joined: 2015-09-11 18:17

Re: Auto Lookup show only exact match

Post by elemire » 2015-09-14 14:01

I spoke to soon, when I changed like to = and type in a value it returns no results even though the value exist in the lookup table. Should I use ==?

User avatar
a.gneady
Site Admin
Posts: 1354
Joined: 2012-09-27 14:46
Contact:

Re: Auto Lookup show only exact match

Post by a.gneady » 2015-09-15 06:24

Hmm .. == is not part of SQL syntax and won't work ... maybe this might work:

Code: Select all

$wheres[] = "{$field['parent_caption']} like '{$search_term}'";
:idea: AppGini plugins to add more power to your apps:

Post Reply