Dynamic Auto Complete with UDF

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Dynamic Auto Complete with UDF

Post by mwalter »

I'm trying to add dynamic auto complete to a text box.
I created a UDF that accepts two parameters. I added this code to the onkeyup event of the text box.

Code: Select all

debugger;
var loc = get("ddLocation");
var chars = get("txtItemLookup");
var url = "http://myIBMI:8080/profoundui/universal/getTransferItems?chars=" + 
         encodeURIComponent(chars) + "&loc=" + 
         encodeURIComponent(loc);
applyProperty("txtItemLookup","choices url", url);
applyProperty("txtItemLookup","field type","textbox");
If I plug the URL into a browser I get the following JSON, which i verified correct using JSONLINT.

Code: Select all

{
	"success": true,
	"response": {
		"colWidths": [13,
		30],
		"results": [{
			"item": "998300",
			"desc": "TOYOTA MULTI 2000 & UP S/DDIN"
		},
		{
			"item": "90580",
			"desc": "EARPLUGS,4PR,DISPOSABLE"
		},
		{
			"item": "993304",
			"desc": "BUICK TERRAZA,SATURN RELAY,PON"
		},
		{
			"item": "911R",
			"desc": "FIRST ALERT, BATTERY OPERATED"
		},
		{
			"item": "90716",
			"desc": "3M TEKKPROTECT REUSE CORDED EA"
		}]
	}
}
However, when I run the program, it doesn't seem that the code is firing.

Can I do this like this, or should I be using some other method?
User avatar
Emily
Profound Logic Staff Member
Posts: 89
Joined: Tue Jun 21, 2016 8:30 am
First Name: Emily
Last Name: Seage
Company Name: Profound Logic
Contact:

Re: Dynamic Auto Complete with UDF

Post by Emily »

Hi mwalter,

Looking at the code that you're using, your problem may be caused by the URL that you're using for the 'choices URL' property. In 'choices URL', you do not need to include the entire URL. So, in your example below, you do not need to include 'http://myIBMI:8080', just the part of the URL that starts with /profoundui/.

Could you try changing this in your 'onkeyup' event and see if this solves the problem you're having?
Emily Seage
Support Team Lead
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Dynamic Auto Complete with UDF

Post by mwalter »

Still not working.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Dynamic Auto Complete with UDF

Post by Scott Klement »

I'm not understanding when you are running this JavaScript code. You say "onkeyup of the text box" -- surely you don't mean the same textbox that has autocomplete configured for it, as that doesn't make any sense. (You'd be asking it to wipe out everything you've done so far when you ask it to re-render the box. You'd haveto type AGAIN after changing this before the autocomplete would run with the new parameters, but since you'd wipe it out again as soon as they typed again... it'd never work... nor does it make sense, since as far as I can tell the criteria doesn't change when you type in the autocomplete box, why would you want to reset everything?)

Do you mean that your "ddLocation" or "txtItemLookup" are textboxes and you are doing it in the onkeyup of those?

Since you seem to be asking the community to troubleshoot your application for you, it'd help an awful lot if you'd provide a code sample we can load and run to reproduce the problem.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Dynamic Auto Complete with UDF

Post by mwalter »

Basically, what I'm trying to do, is replicate an application I saw you develop at the Plus conference last year, when you were doing the item number lookup. I tried to find it, but I can't seem to locate the video.

It sent an ajax call to a UDF program for each keyup event to narrow down your search. The reason I wanted to do it this way, and not just use the the database driven autocomplete is that the criteria that returns the data is very dynamic.

Does this make sense?
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Dynamic Auto Complete with UDF

Post by mwalter »

I got around the problem by creating a view and creating selection criteria on that in the Database Driven Auto Complete.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests