You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-13Lines changed: 25 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,12 @@
3
3
Angular Dual-Listbox
4
4
=========
5
5
6
-
The **angular-dual-listbox** is an Angular 4+ component that provides two lists controls
7
-
side-by-side that allows items in one list to be moved to the other list via drag-and-drop and/or a
8
-
button-based interface. The component supports multiple select options from the list, programatic
9
-
setting of list sources, and layout with direction and button formatting.
6
+
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 selected and 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.
10
7
11
8
A [working demo](http://czeckd.github.io/angular-dual-listbox/demo/) shows the dual listbox in action.
12
9
10
+
\* Technically, the dual-list component does not move items from one array to another. Rather it makes a copy from the source array of the item and adds it to the destination array, or removes it from the destination array. Thus, the source array is a master list of all available item and the destintion array is a list of items that have been selected from the master list. Therefore, in order for an item to be in the destination array it must also exist in the source array.
@@ -28,8 +27,7 @@ import { AngularDualListBoxModule } from 'angular-dual-listbox';
28
27
})
29
28
exportclassAppModule {}
30
29
```
31
-
See also the [basic-dual-list-demo](https://github.com/czeckd/basic-dual-listbox-demo) for a sample project using this module.
32
-
30
+
See also the [basic-dual-list-demo](https://github.com/czeckd/basic-dual-listbox-demo) for a sample project using this module. Note that the default component uses Bootstrap 3 for styling and so the bootstrap.css would need to be included in the project for it to be styled correctly. That said, the styles can be overriden with your own style sheet or fully customized by extending the `DualListComponent` and providing a new template. For more details, see the section on **Extending** below.
33
31
34
32
## Usage
35
33
Basic usage is:
@@ -38,22 +36,36 @@ Basic usage is:
38
36
```
39
37
The following parameters can be set on a dual-list:
40
38
-**key** - The unique identifier field of each object in the `source` and
41
-
`destination` arrays, default is ``_id``. (With a source of an array of strings, each string is its own id.)
39
+
`destination` arrays, default is ``_id``. (Note: with a source of an array of strings, each string is its own id.)
42
40
-**display** - The field of each object for displaying the object each the
43
-
lists, default is ``_name``. (With a source of an array of strings, each string is its own display.)
41
+
lists, default is ``_name``. Or, a function that returns a string that can be used for displaying an object. (Note: with a source of an array of strings, each string is its own display.)
44
42
-**height** - The height of the lists, default is ``100px``.
45
-
-**format** - A format object, default is ``{ add: 'Add', remove: 'Remove', all: 'All', none: 'None', direction: 'left-to-right', draggable: true }``
43
+
-**format** - A format object, default is ``{ add: 'Add', remove: 'Remove', all: 'All', none: 'None', direction: 'left-to-right', draggable: true, locale: undefined }``
46
44
-**filter** - A boolean whether or not to display a filter for the lists, default is ``false``.
47
45
-**sort** - A boolean whether or not to keep the lists sorted, default is ``false``.
48
46
-**compare** - A compare function to be used for sorting the lists. Note if
49
47
sort is not set and compare is set, then sort will be set ``true``.
50
48
-**source** - The source array of objects or strings for the list. (This is the universal, master list of all possible objects.)
51
-
-**destination** The destination array of objects or strings selected from the source.
52
-
Note, the ``destination`` array can have prexisting elements.
49
+
-**destination** The destination array of objects or strings selected from the source. Note, the ``destination`` array can have prexisting elements.
53
50
-**disabled** - The dual-list is disabled, default is ``false``.
54
51
55
52
For more usage examples, see the [`demo-app.component.ts`](https://github.com/czeckd/angular-dual-listbox/blob/master/app/demo-app.component.ts).
56
53
54
+
## Format
55
+
The format object allows for the text for the add, remove, all, and none buttons to be set. It also can be used to set the layout direction with the source being on the left-hand side as the default, toggling drag-and-drop, and explicitly setting the locale for the filter string comparision. The default locale is undefined and will use host environment's current locale. An example format object:
See [`dual-list.component.html`](https://github.com/czeckd/angular-dual-listbox/blob/master/lib/dual-list.component.html) and
73
-
[`dual-list.component.css`](https://github.com/czeckd/angular-dual-listbox/blob/master/lib/dual-list.component.css) for template and style guidance.
84
+
See [`dual-list.component.html`](https://github.com/czeckd/angular-dual-listbox/blob/master/lib/dual-list.component.html) and [`dual-list.component.css`](https://github.com/czeckd/angular-dual-listbox/blob/master/lib/dual-list.component.css) for template and style guidance.
85
+
74
86
There is also an Angular-CLI seed project, [custom-dual-listbox](https://github.com/czeckd/custom-dual-listbox), available with an example of a
0 commit comments