Code Monkey home page Code Monkey logo

groupedcombobox's Introduction

GroupedCombobox

GroupedCombobox is a most neat and clean implementation for lightning grouped combobox.

Get Started

GroupedCombobox is fairly easy to use. The codebase contains one lwc file for grouped combobox and another aura component for testing purpose. To get started, checkout out this repo and import groupedCombobox lwc component.

Here is the sample code to use this lwc component in aura component:

<aura:component implements="lightning:isUrlAddressable" access="global">
    <aura:attribute name="items" type="Object"/>

    <aura:handler name="init" value="{! this }" action="{! c.doInit }" />

    <div class="panel">
        <c:groupedCombobox
            name="groupedCombobox"
            label="Grouped Combobox"
            options="{! v.items }"
        >
        </c:groupedCombobox>
    </div>
</aura:component>

And the data source is simple:

({
    doInit: function(component, event, helper) {
        const items = [
            {
                label: 'Group 1',
                items: [
                    {
                        label: 'Option 1',
                        value: 'option1',
                    },
                    {
                        label: 'Option 2',
                        value: 'option2',
                    },
                ],
            },
            {
                label: 'Group 2',
                items: [
                    {
                        label: 'Option 3',
                        value: 'option3',
                    },
                    {
                        label: 'Option 4',
                        value: 'option4',
                    },
                ],
            },
        ];

        component.set('v.items', items);
    },
})

Here is the screen snapshot: GroupedCombobox

Pros and Cons

Pros

This implementation extends the standard lightning combobox and expose the builtin support for grouped combobox. Therefore, all OOTB features of the lightning combobox will be inherited.

Cons

This implementation relies on the knowledge of the lightning combobox base class, so in case lightning combobox base class internal implementation changes, this grouped combobox will also have to be modified accordingly.

groupedcombobox's People

Contributors

liumiaowilson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.