Code Monkey home page Code Monkey logo

sfdc-ui-lookup's Introduction

Salesforce Lightning Lookup Component

Lookup animation

Lookup with dropdown open

About

This is a generic & customizable lookup component built using Salesforce Lightning and SLDS style.
It does not rely on third party libraries and you have full control over its datasource.

Features

The Lightning Lookup component provides the following features:

  • customizable data source that can return mixed sObject types
  • single or multiple selection mode
  • client-side caching & request throttling
  • built-in server request rate limit mechanism

Multiple or single entry lookup

Documentation

The Lookup Lightning component is documented using Aura documentation.
You can access it from this URL (replace the domain):
https://<YOUR_DOMAIN>.lightning.force.com/auradocs/reference.app#reference?descriptor=c:Lookup&defType=component

Prior to using the Lookup component, it is your responsibility to implement an Apex @AuraEnabled method (SampleLookupController.search in our samples) that returns the search results as a List<LookupSearchResult>. The method name can be different but it needs to match this signature:

@AuraEnabled
public static List<LookupSearchResult> search(String searchTerm, List<String> selectedIds) {}

The Lookup component exposes an onSearch component event that is fired when a search needs to be performed on the server-side. The parent component that contains the lookup must handle the onSearch event:

<c:Lookup aura:id="lookup" selection="{!v.selection}" onSearch="{!c.lookupSearch}" label="Search"/>

The event handler should do the following:

lookupSearch : function(component, event, helper) {
    // Get the Apex server-side action associated with this search (`search` in our samples)
    const serverSearchAction = component.get('c.search');
    // Passes the action to the Lookup component by calling the `search` aura method
    component.find('lookup').search(serverSearchAction);
}

Salesforce DX setup instructions

Deploy the sample application with Salesforce DX by clicking on this button:

Deploy

Sample application

The default installation installs the Lookup component and a sample application available under this URL (replace the domain):
https://<YOUR_DOMAIN>.lightning.force.com/c/SampleLookupApp.app

If you wish to install the project without the sample application, edit sfdx-project.json and remove the src-sample path.

sfdc-ui-lookup's People

Contributors

pozil avatar

Watchers

James Cloos avatar Justin Lyon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.