function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jpushpanjpushpan 

How to mimic lookup field behaviour on html input field

I am new to visualforce development and I have a question regarding lookup fields.

 

I have a visualforce page in which I am displaying data using jqgrid. The controller returns json data, which is consumed by the jqgrid. This works fine.

When I select and edit a row,  jqgrid generates a form dyanmically with HTML input field based on the column definition given  and prepopulates the data for that row  under each field.

Now my problem is , one of the field in the form is a look up field  and I want to show the lookupfield icon next to the field. in otherwords, I want to mimic the behaviour of lookup field on a html input field.

 

Does any one have suggestions on how this can be done?

 

Help much appreciated.

jackson

dwwrightdwwright

A trick I used to accomplish this once is to create a dummy "placeholder" variable in my controller of an sObject that has a lookup field to the table I want to search. You can then just create a new instance of this object (you don't even have to insert it, just initialize it in your controller) and assign the lookup field of that variable to an <apex:inputfield> component.This will allow you to search the database via the lookup field, and then you can just assign the results (which will be in the field) to whatever you need.

ricardcabreraricardcabrera

It works! Thanks for the trick!!  :smileyvery-happy: