• Cooper 13
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi All

I have tried to create multiselect picklist dropdown through LWC but here values are hardcoded. You can see my Code Below:

Demo.html

<template>
    <!-- picklistlabel sets the label to multi select combobox -->
   
    <c-mutli-select-picklist picklistlabel="Industry" values={values} ></c-mutli-select-picklist>
</template>

demo.js

import { LightningElement, track, api } from 'lwc';
export default class Demo extends LightningElement {
    //This array can be anything as per values
    values =    [{label : 'Agriculture', value : 'Agriculture', selected : false},
                {label : 'Banking', value : 'Banking', selected : false},
                {label : 'Chemicals', value : 'Chemicals'},
                {label : 'Education', value : 'Education'},
                {label : 'Finance', value : 'Finance'}];
               
    //To get the picklist values in container component
    fetchSelectedValues(){
        let selections = this.template.querySelector('c-mutli-select-picklist');
        console.log(selections.values);
    }
}

Demo.js meta

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__HomePage</target>
      </targets>
</LightningComponentBundle>

 

Requirement: 

Object: Account and Field: Industry

I want that through apex class all the picklist value of industry would be visible in dropdown instead of hardcoded value.

Can anybody help me to make it dynamic.

Thanks in Advance

Hi All

I have tried to create multiselect picklist dropdown through LWC but here values are hardcoded. You can see my Code Below:

Demo.html

<template>
    <!-- picklistlabel sets the label to multi select combobox -->
   
    <c-mutli-select-picklist picklistlabel="Industry" values={values} ></c-mutli-select-picklist>
</template>

demo.js

import { LightningElement, track, api } from 'lwc';
export default class Demo extends LightningElement {
    //This array can be anything as per values
    values =    [{label : 'Agriculture', value : 'Agriculture', selected : false},
                {label : 'Banking', value : 'Banking', selected : false},
                {label : 'Chemicals', value : 'Chemicals'},
                {label : 'Education', value : 'Education'},
                {label : 'Finance', value : 'Finance'}];
               
    //To get the picklist values in container component
    fetchSelectedValues(){
        let selections = this.template.querySelector('c-mutli-select-picklist');
        console.log(selections.values);
    }
}

Demo.js meta

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__HomePage</target>
      </targets>
</LightningComponentBundle>

 

Requirement: 

Object: Account and Field: Industry

I want that through apex class all the picklist value of industry would be visible in dropdown instead of hardcoded value.

Can anybody help me to make it dynamic.

Thanks in Advance