I created a simple lookup component in Lightning. Its fully based on Lightning Design Systems. You can check the Github link in the reference section. During initialization, the component query for the list of strings (using apex code) to be displayed and store in an attribute. So when the user enters a search keyword, the request won't go to Salesforce again and will query the Javascript string array for the filtered results.
How to use?
From your Lightning component, add a lookup component using the following markup:<c:DemoLookup placeholder="Enter partner Name" actionMethod="c.getAccountOptions"/>
You need to pass a list of strings which will get displayed in the lookup options when the user enters an input. A sample method is as below:
@AuraEnabled
public static List<String> getAccountOptions() {
List<String> options = new List<String>();
for (Account a : [
SELECT Name
FROM Account
LIMIT 100
]) {
options.add(a.Name);
}
return options;
}
Reference:
https://github.com/iamsonal/DemoLookup
can we show a spinner inside the lookup? when data is taking time to load
ReplyDelete