Quantcast
Channel: blog.
Viewing all articles
Browse latest Browse all 20

Autocomplete component

$
0
0
Hello everyone, just wanted to share with the community this custom component I made and give something back for the help I've received :)

The purpose of the component is to enable autocomplete in lookup fields. I used the autocomplete js created by Jim Roos:
(http://www.jimroos.com/2007/05/ajax-autocomplete.html) but made some modifications to it so that it could interact with an Apex controller among some other things...

So my idea was that if you were making a VF page that had an inputfield that was related to a lookupfield you would just insert this autocomplete component to that inputfield.

Something like this:
<apex:inputField value="{!Contact.accountid}" id="accname" styleClass="cField">

<c:autocomplete ObjectName="Accounts" InputId="{!$Component.accname}"

AutoCompleteId="accACid" ClassName="autocomplete300"/>

</apex:inputField>

The component has 4 parameters:

The name of the object or custom object that the inputfield relates to (new objects must be added inside the apex classes since i had some problems constructing a dynamic query).
The InputId which is used to relate the component to the input field
The id for the Component
A classname parameter that basically just defines the width of the suggestions menu.

Here's a screenshot of how it looks like in action:





Here's a link to the file containing the required files:

Autocomplete Component

Viewing all articles
Browse latest Browse all 20

Trending Articles