ngx-bootstrap-multiselect-dropdown
Version:
Simple multiselect dropdown based on bootstrap 4 dropdown component.
171 lines (167 loc) • 5.03 kB
Markdown
# NgxBootstrapMultiselectDropdown
<h4>Install</h4>
<p>
npm install ngx-bootstrap-multiselect-dropdown
</p>
<br>
<h4>Example</h4>
<p>
Add "node_modules/bootstrap/dist/css/bootstrap.min.css" to angular.json styles.
</p>
<h5>Register module</h5>
<code>
import { NgxBootstrapMultiselectDropdownModule } from 'ngx-bootstrap-multiselect-dropdown/ngx-bootstrap-multiselect-dropdown';<br><br>
@NgModule({<br>
 declarations: [<br>
  AppComponent<br>
 ],<br>
 imports: [<br>
  BrowserModule,<br>
  <b>NgxBootstrapMultiselectDropdownModule</b>,<br>
  FormsModule<br>
 ],<br>
 providers: [],<br>
 bootstrap: [AppComponent]<br>
})<br>
export class AppModule { }<br>
</code>
<h5>Setup</h5>
<code>
this.dropdownList = [<br>
  {"idValue":1,"nameValue":"India"},<br>
  {"idValue":2,"nameValue":"Singapore"},<br>
  {"idValue":3,"nameValue":"Australia"},<br>
  {"idValue":4,"nameValue":"Canada"},<br>
  {"idValue":5,"nameValue":"South Korea"},<br>
  {"idValue":6,"nameValue":"Germany"},<br>
  {"idValue":7,"nameValue":"France"},<br>
  {"idValue":8,"nameValue":"Russia"},<br>
  {"idValue":9,"nameValue":"Italy"},<br>
  {"idValue":10,"nameValue":null}<br>
];<br>
<br>
this.selectedItems = [];<br>
<br>
this.dropdownSettings = {<br>
  dataIdProperty: "idValue",<br>
  dataNameProperty: "nameValue",<br>
  headerText: "Test header",<br>
  noneSelectedBtnText: "All selected",<br>
  btnWidth: "200px",<br>
  dropdownHeight: "200px",<br>
  showDeselectAllBtn: true,<br>
  showSelectAllBtn: true,<br>
  deselectAllBtnText: 'Deselect',<br>
  selectAllBtnText: 'Select',<br>
  btnClasses: 'btn btn-primary btn-sm dropdown-toggle',<br>
  selectionLimit: 3,<br>
  enableFilter: true<br>
};<br>
<br>
</code>
<p>
<ngx-bootstrap-multiselect
name="selectedItems"
[(ngModel)]="selectedItems"
[items]="dropdownList"
[settings]="dropdownSettings">
</ngx-bootstrap-multiselect>
</p>
<br>
<h4>Settings</h4>
<table class="table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Default value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>dropdownHeight</th>
<td>string</td>
<td>'auto'</td>
<td>Sets the height of the dropdown.</td>
</tr>
<tr>
<th>btnWidth</th>
<td>string</td>
<td>'auto'</td>
<td>Width of the dropdown toggle button.</td>
</tr>
<tr>
<th>noneSelectedBtnText</th>
<td>string</td>
<td>'None selected'</td>
<td>Button text when no dropdown items are selected</td>
</tr>
<tr>
<th>dataIdProperty</th>
<td>string</td>
<td>'id'</td>
<td>Name of 'ID' property belonging to dropdown items.</td>
</tr>
<tr>
<th>dataNameProperty</th>
<td>string</td>
<td>'name'</td>
<td>Name of 'Name' property belonging to dropdown items.</td>
</tr>
<tr>
<th>deselectAllBtnText</th>
<td>string</td>
<td>'Deselect all'</td>
<td>Text of deselect all button.</td>
</tr>
<tr>
<th>selectAllBtnText</th>
<td>string</td>
<td>'Select all'</td>
<td>Text of select all button.</td>
</tr>
<tr>
<th>enableFilter</th>
<td>boolean</td>
<td>false</td>
<td>Show dropdown item filter text input.</td>
</tr>
<tr>
<th>dropdownClasses</th>
<td>string</td>
<td>-</td>
<td>Additional CSS classes added to dropdown menu.</td>
</tr>
<tr>
<th>headerText</th>
<td>string</td>
<td>-</td>
<td>Text displayed at top of dropdown menu.</td>
</tr>
<tr>
<th>selectionLimit</th>
<td>number</td>
<td>-</td>
<td>Limit number of how many dropdown items can be selected.</td>
</tr>
<tr>
<th>showDeselectAllBtn</th>
<td>boolean</td>
<td>-</td>
<td>Show deselect all button on dropdown menu.</td>
</tr>
<tr>
<th>showSelectAllBtn</th>
<td>boolean</td>
<td>-</td>
<td>Show select all button on dropdown menu.</td>
</tr>
<tr>
<th>btnClasses</th>
<td>string</td>
<td>-</td>
<td>Additional CSS classes added to dropdown menu toggle button.</td>
</tr>
</tbody>
</table>