Giter VIP home page Giter VIP logo

dijit-select-optgroup's Introduction

SelectOptgroup

SelectOptgroup is a styleable, searchable drop down select box for Dojo Toolkit which includes grouping of options (similar to html <select> element with <optgroup>).

SelectOptgroup extends dijit.form.Select maintaining its API and core functionalities.

Try live example.


Great! So how do I use it?

  • For npm users, add this dependecy in your package.json: "dependencies": { "dijit-select-optgroup": "^1.0.0" } and run npm install.
  • For Bower users, add this dependecy in your bower.json: "dependencies": { "dijit-select-optgroup": "^1.0.0" } and run bower install.

How do I run the example?

  • First install all dependencies using: npm install.
  • Now run your local server: gulp connect.
  • Open the example: gulp example.

API

SelectOptgroup uses the same API for dijit.form.Select, the only difference is the optgroup property, which can be optionally passed in the objects for property options to differentiate the item in the list.

Example

var instance = new SelectOptgroup({
    options: [
        {
            label: 'Optgroup item',
            value: '',
            optgroup: true // mark menu item as optgroup
        },
        {
            label: 'Option item',
            value: 'option '// mark menu item as option
        },
        {
            label: '', // empty strings mark menu item as separator
            value: ''
        },
        {
            label: '<div class="SelectOptgroup__nested"><span class="select__icon">Icon Text</span></div>', // html allowed in menu item
            value: 'grunt'
        }
    ]
}, 'domId');

Customization

You can customize the default layout for the entire component using CSS.

SelectOptgroup add by default two CSS classes SelectOptgroup__flattened and SelectOptgroup__nested.

Example

    .SelectOptgroup__flattened .dijitMenuItemLabel {
         /* style menu item as optgroup */
        padding-left: 0 !important;
    }

    .SelectOptgroup__nested .dijitMenuItemLabel {
        /* style menu item as option */
        padding-left: 25px !important;
    }

Working example available at this page.

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.