Two Columns Multi-Select Picklist Lightning Component


Note : From API Version 41.0 and later you can use lightning:dualListBox for the same.
for more information refer Lightning component developer guide

Two Columns multi-select is one of the frequently required functionality in web development. MultiselectPicklist is a Lightning Component developed for the same. It can be used easily in lightning components as well as in visualforce pages.

Component Name: MultiselectPicklist
Required Attribute: name=availablePickList, type= String []
Usage:
  1. In Lightning component / Lightning App :
Syntax : 
<c:MultiselectPicklist availablePickList= List of picklist/>
Eg.
<c:MultiselectPicklist availablePickList="['spray', 'limit','elite', 'exuberant', 'destruction', 'present']"/> 
  1. In Visualforce Page :
To use this component in Visualforce page, create an App which extends ltng:outApp. Set Dependency In Lightning App. Refer TestApp

TestApp: 
<aura:application access="global" extends="ltng:outApp">
<aura:dependency resource="c:MultiselectPicklist">
</aura:dependency></aura:application>

TwoColumnsMultiSelectVFpage:
<apex:page >

<apex:includeLightning />

<div id="multiselectDiv" />

<script>

$Lightning.use("c:TestApp", function() {

$Lightning.createComponent("c:MultiselectPicklist",

{availablePickList : ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']},

'multiselectDiv',

function(cmp) {

console.log('component created successfully')

});

});

</script>

</apex:page>


You can download MultiselectPicklist lightning component from here.

How it looks:


Comments

  1. lightning:dualListbox base component is already available for similar use case.

    ReplyDelete
    Replies
    1. Thanks Brahmaji. I was not aware of this component. Thanks for sharing.

      Delete

Post a Comment

Popular posts from this blog

Uploading multiple files as attachments using chaining of actionfunction in single click.

Dynamic Visualforce Bindings with Example