Code Monkey home page Code Monkey logo

angular-dual-listbox's Introduction

npm version

Angular Dual-Listbox

The angular-dual-listbox is an Angular 4+ component that provides two lists controls side-by-side that allows items in one list to be moved to the other list via drag-and-drop and/or a button-based interface. The component supports multiple select options from the list, programatic setting of list sources, and layout with direction and button formatting.

A working demo shows the dual listbox in action.

Dual ListBox

How to use?

$ npm i angular-dual-listbox --save

Integration

The angular-dual-listbox should work as-is with webpack/angular-cli. Just add the AngularDualListBoxModule:

import { AngularDualListBoxModule } from 'angular-dual-listbox';

@NgModule({
    imports: [ AngularDualListBoxModule ],
    ...
})
export class AppModule {}

See also the basic-dual-list-demo for a sample project using this module.

Usage

Basic usage is:

<dual-list [source]="source" [(destination)]="confirmed"></dual-list>

The following parameters can be set on a dual-list:

  • key - The unique identifier field of each object in the source and destination arrays, default is _id. (With a source of an array of strings, each string is its own id.)
  • display - The field of each object for displaying the object each the lists, default is _name. (With a source of an array of strings, each string is its own display.)
  • height - The height of the lists, default is 100px.
  • format - A format object, default is { add: 'Add', remove: 'Remove', all: 'All', none: 'None', direction: 'left-to-right' }
  • filter - A boolean whether or not to display a filter for the lists, default is false.
  • sort - A boolean whether or not to keep the lists sorted, default is false.
  • compare - A compare function to be used for sorting the lists. Note if sort is not set and compare is set, then sort will be set true.
  • source - The source array of objects or strings for the list. (This is the universal, master list of all possible objects.)
  • destination The destination array of objects or strings selected from the source. Note, the destination array can have prexisting elements.

For more usage examples, see the demo-app.component.ts.

Extending

The html template packaged with this component is based on Bootstap 3; however it can be overridden for customization. Here is an example:

import { Component } from '@angular/core';
import { DualListComponent } from 'angular-dual-listbox/dual-list.component';

@Component({
    selector: 'custom-dual-list',
    templateUrl: './custom-dual-list.component.html',
    styleUrls: [ './custom-dual-list.component.css' ]
})
export class CustomDualListComponent extends DualListComponent {
}

See dual-list.component.html and dual-list.component.css for template and style guidance. There is also an Angular-CLI seed project, custom-dual-listbox, available with an example of a customized view and extended functionality.

License

MIT

Author

angular-dual-listbox's People

Contributors

czeckd avatar

Watchers

James Cloos 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.