Skip to content

Commit be9d037

Browse files
authored
Merge pull request #133 from chris--jones/develop
Updated README.md
2 parents 9537681 + ff74448 commit be9d037

File tree

1 file changed

+64
-22
lines changed

1 file changed

+64
-22
lines changed

README.md

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,50 +60,92 @@ In your template, use the component directive:
6060

6161
## Customize
6262

63-
Import the IMultiSelectOption and IMultiSelectTexts interfaces to enable/override settings and text strings:
63+
Import the `IMultiSelectOption` and `IMultiSelectTexts` interfaces to enable/override settings and text strings:
6464
```js
65-
optionsModel: number[] = [1, 2]; // Default selection
6665

66+
// Default selection
67+
optionsModel: number[] = [1, 2];
68+
69+
// Settings configuration
6770
mySettings: IMultiSelectSettings = {
68-
pullRight: false,
69-
enableSearch: false,
70-
checkedStyle: 'checkboxes',
71-
buttonClasses: 'btn btn-default btn-secondary',
72-
selectionLimit: 0,
73-
closeOnSelect: false,
74-
autoUnselect: false,
75-
showCheckAll: false,
76-
showUncheckAll: false,
77-
fixedTitle: false,
71+
enableSearch: true,
72+
checkedStyle: 'fontawesome',
73+
buttonClasses: 'btn btn-default btn-block',
7874
dynamicTitleMaxItems: 3,
79-
maxHeight: '300px',
75+
displayAllSelectedText: true
8076
};
8177

78+
// Text configuration
8279
myTexts: IMultiSelectTexts = {
83-
checkAll: 'Check all',
84-
uncheckAll: 'Uncheck all',
85-
checked: 'checked',
86-
checkedPlural: 'checked',
87-
searchPlaceholder: 'Search...',
80+
checkAll: 'Select all',
81+
uncheckAll: 'Unselect all',
82+
checked: 'item selected',
83+
checkedPlural: 'items selected',
84+
searchPlaceholder: 'Find',
8885
defaultTitle: 'Select',
8986
allSelected: 'All selected',
9087
};
9188

92-
/* Labels */
89+
// Labels / Parents
9390
myOptions: IMultiSelectOption[] = [
9491
{ id: 1, name: 'Car brands', isLabel: true },
9592
{ id: 2, name: 'Volvo', parentId: 1 },
96-
{ id: 3, name: 'Colors', isLabel: true },
97-
{ id: 4, name: 'Blue', parentId: 3 }
93+
{ id: 3, name: 'Honda', parentId: 1 },
94+
{ id: 4, name: 'BMW', parentId: 1 },
95+
{ id: 5, name: 'Colors', isLabel: true },
96+
{ id: 6, name: 'Blue', parentId: 5 },
97+
{ id: 7, name: 'Red', parentId: 5 },
98+
{ id: 8, name: 'White', parentId: 5 }
9899
];
99100

100101
```
101102

102103
```html
103104
<ss-multiselect-dropdown [options]="myOptions" [texts]="myTexts" [settings]="mySettings" [(ngModel)]="optionsModel"></ss-multiselect-dropdown>
104105
```
106+
### Settings
107+
| Setting | Description | Default Value |
108+
| -------------------- | ------------------------------------------------------------------ | ---------------- |
109+
| pullRight | Float the dropdown to the right | false |
110+
| enableSearch | Enable searching the dropdown items | false |
111+
| checkedStyle | Style of checked items one of 'checkboxes', 'glyphicon' or 'fontawesome' | 'checkboxes' |
112+
| buttonClasses | CSS classes to apply to the trigger button | 'btn btn-default' |
113+
| itemClasses | CSS classes to apply to items | '' |
114+
| selectionLimit | Maximum number of items that may be selected (0 = no limit) | 0 |
115+
| autoUnselect | Unselect the previous selection(s) once selectionLimit is reached | false |
116+
| closeOnSelect | If enabled, dropdown will be closed after selection | false |
117+
| showCheckAll | Display the `checkAll` item to select all options | false |
118+
| showUncheckAll | Display the `uncheckAll` item to unselect all options | false |
119+
| fixedTitle | Use the default title (do not apply the dynamic title) | false |
120+
| dynamicTitleMaxItems | The maximum number of options to display in the dynamic title | 3 |
121+
| maxHeight | The maximum height for the dropdown (including unit) | '300px' |
122+
| displayAllSelectedText | Display the `allSelected` text when all options are selected | false |
123+
124+
### Texts
125+
| Text Item | Description | Default Value |
126+
| --------------------- | ------------------------------------------ | ---------------- |
127+
| checkAll | The text for the "check all" option | 'Check all' |
128+
| uncheckAll | The text for the "uncheck all" option | 'Uncheck all' |
129+
| checked | Text for "checked" with single item selected (used in dynamic title) | 'checked' |
130+
| checkedPlural | Text for "checked" with multiple items selected (used in dynamic title) | 'checked' |
131+
| searchPlaceholder | Text initially displayed in search input | 'Search...' |
132+
| defaultTitle | Title displayed in button before selection | 'Select' |
133+
| allSelected | Text displayed when all items are selected (must be enabled in options) | 'All selected' |
134+
135+
## Other examples
136+
137+
### Single select
138+
Although this dropdown is designed for multiple selections, a common request is to only allow a single selection without requiring the user to unselect their previous selection each time. This can be accomplished by setting selectionLimit to 1 and autoUnselect to true.
139+
```
140+
{
141+
...
142+
selectionLimit: 1,
143+
autoUnselect: true,
144+
...
145+
}
146+
```
105147

106-
## Use model driven forms with ReactiveFormsModule:
148+
### Use model driven forms with ReactiveFormsModule:
107149

108150
```js
109151
import { IMultiSelectOption } from 'angular-2-dropdown-multiselect';

0 commit comments

Comments
 (0)