All Projects → Crazyht → Ngx Tree Select

Crazyht / Ngx Tree Select

Licence: mit
Angular select component with tree items

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ngx Tree Select

Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+1647.46%)
Mutual labels:  library, treeview, angular4
Ngx Select Dropdown
Custom Dropdown for Angular 4+ with multiple and single selection options
Stars: ✭ 91 (+54.24%)
Mutual labels:  library, select, angular4
Ngx Excel Export
Angular6 application with export data to excel file functionality.
Stars: ✭ 58 (-1.69%)
Mutual labels:  angular4, ngx
Angular Google Maps
Angular 2+ Google Maps Components
Stars: ✭ 1,982 (+3259.32%)
Mutual labels:  library, angular4
select2-to-tree
Select2-to-Tree extends Select2 to support arbitrary level of nesting...
Stars: ✭ 71 (+20.34%)
Mutual labels:  select, treeview
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+4613.56%)
Mutual labels:  select, angular4
Egeo
EGEO is the open-source UI library used to build Stratio's UI. It includes UI Components, Utilities, Services and much more to build user interfaces quickly and with ease. The library is distributed in AoT mode.
Stars: ✭ 69 (+16.95%)
Mutual labels:  library, angular4
Teaset
A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.
Stars: ✭ 2,845 (+4722.03%)
Mutual labels:  library, select
Truly Ui
Truly-UI - Web Angular UI Components for Desktop Applications (Electron, NW, APP JS)
Stars: ✭ 195 (+230.51%)
Mutual labels:  library, angular4
Ngx Scroll To
Scroll to any element to enhance scroll-based features in you app. Works for Angular 4+, both AoT and SSR. No dependencies.
Stars: ✭ 269 (+355.93%)
Mutual labels:  angular4, ngx
Ngx Drag To Select
A lightweight, fast, configurable and reactive drag-to-select component for Angular 6 and beyond
Stars: ✭ 262 (+344.07%)
Mutual labels:  select, ngx
Ngx Ui
🚀 Style and Component Library for Angular
Stars: ✭ 534 (+805.08%)
Mutual labels:  library, select
Ngx File Drop
Angular 11 file and folder drop library
Stars: ✭ 220 (+272.88%)
Mutual labels:  angular4, ngx
Ngx Daterangepicker Material
Pure Angular 2+ date range picker with material design theme, a demo here:
Stars: ✭ 169 (+186.44%)
Mutual labels:  angular4, ngx
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (+333.9%)
Mutual labels:  library, angular4
Angular2 Carousel
An lightweight , touchable and responsive library to create a carousel for angular 2 / 4 / 5
Stars: ✭ 26 (-55.93%)
Mutual labels:  angular4, ngx
Angulartics2
Vendor-agnostic analytics for Angular2 applications.
Stars: ✭ 963 (+1532.2%)
Mutual labels:  angular4, ngx
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-3.39%)
Mutual labels:  library
Lcformvalidation
Javascript based form validation library, third party library / framework agnostic.
Stars: ✭ 58 (-1.69%)
Mutual labels:  library
Bootstraptable Treeview
bootstrapTable extension of treeView
Stars: ✭ 57 (-3.39%)
Mutual labels:  treeview

Ngx-tree-select

Greenkeeper badge Build Status npm version

Features:

  • Dropdown with 'flat' items (Like normal select)
  • Dropdown with hierarchical items
  • Simple or multiple selected items
  • With hierarchical datas you can force child selection or allow select parent
  • ngModel & standard validation compliant
  • Can limit displayed selected items (... link allow your user to see entire selection)

Installation

This is how to install the components:

npm install ngx-tree-select

or

yarn add ngx-tree-select

And on your application module:

import {NgxTreeSelectModule} from 'ngx-tree-select';

@NgModule({
  declarations: [ ...],
  imports: [
    BrowserModule,
    ....,
    NgxTreeSelectModule.forRoot({
      allowFilter: true,
      filterPlaceholder: 'Type your filter here...',
      maxVisibleItemCount: 5,
      idField: 'id',
      textField: 'name',
      childrenField: 'children',
      allowParentSelection: true
    })
],
})
export class AppModule { }

See below for SystemJs / UMD installation.

Default options

When you call NgxTreeSelectModule.forRoot you must pass default options. This options can be empty object "{}" or you can add one or more settings :

  • allowFilter : display filter input on dropdown
  • filterPlaceholder : determine placeholder text for filter
  • maxVisibleItemCount : determine maximum number of items are displayed on multiple select
  • idField : determine which property of your items is used as unique identifier
  • textField : determine which property of your items is displayed
  • childrenField : determine which property of yours items contains children items
  • allowParentSelection : if set to true, you can select parent, else when you select parent all children are selected
  • expandMode : Define which item are expand at initilization. Possible value are : None, Selection or All

Using the Tree Select

We will need to add first a version of Font Awesome to our page, for example:

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

Then we can use the Tree Select like this:

<form novalidate>
  <tree-select name="simpleSelect"
              [items]="items"
              childrenField="children"
              [(ngModel)]="simpleSelected"
              required=true
              #simpleSelect="ngModel"
              [filterPlaceholder]="FilterPlaceholder"
              [allowFilter]="ShowFilter"
              [disabled]="Disabled"
              [allowParentSelection]="AllowParentSelection"
              expandMode="all"></tree-select>
  <div *ngIf="simpleSelect.errors && (simpleSelect.dirty || simpleSelect.touched)" class="alert alert-danger">
    <div [hidden]="!simpleSelect.errors.required">Simple select is required</div>
  </div>
</form>

<form novalidate>
  <tree-select name="multipleSelect"
              [items]="items"
              childrenField="children"
              [multiple]="true"
              [(ngModel)]="multipleSelected"
              filterPlaceholder="Type item filter..."
              required=true
              minlength="2"
              maxlength="4"
              [allowParentSelection]="AllowParentSelection"
              #multipleSelect="ngModel"
              [filterPlaceholder]="FilterPlaceholder"
              [maxVisibleItemCount]="MaxDisplayed"
              [allowFilter]="ShowFilter"
              [disabled]="Disabled">
  </tree-select>
  <div *ngIf="multipleSelect.errors && (multipleSelect.dirty || multipleSelect.touched)" class="alert alert-danger">
    <div [hidden]="!multipleSelect.errors.required">Multiple select is required</div>
    <div [hidden]="!multipleSelect.errors.minlength">You must choose at least 2 items on Multiple select</div>
    <div [hidden]="!multipleSelect.errors.maxlength">You must choose maximum 4 items on Multiple select</div>
  </div>

Component attributes

When you place tree-select on HTML template you can define :

  • items : list of items
  • multiple : allow multiple selection
  • disabled : disable component
  • allowFilter : display filter input on dropdown
  • filterPlaceholder : determine placeholder text for filter
  • maxVisibleItemCount : determine maximum number of items are displayed on multiple select
  • idField : determine which property of your items is used as unique identifier
  • textField : determine which property of your items is displayed
  • childrenField : determine which property of yours items contains children items
  • allowParentSelection : if set to true, you can select parent, else when you select parent all children are selected
  • expandMode : Define which item are expand at initilization. Possible value are : None, Selection or All

tree-select component use default options define when you call NgxTreeSelectModule.forRoot except if you override it with attribute on HTML template.

Running the Demo Application

This command will build and start the demo application:

npm start

Running This Module In Development

First let's build the library using this command:

npm run lib:build

Then let's link it:

cd dist_package\ngx-tree-select
npm link

On another folder on the same machine where we have for example a running Angular CLI, we then do:

npm link ngx-tree-select

Running the Tests

The tests can be executed with the following commands:

npm run test
npm run e2e

Using SystemJs via the UMD bundle ?

Make sure to add this to your map configuration, if you need the module served from a CDN:

map: {

   ...
   'ngx-tree-select': 'https://unpkg.com/[email protected]<version number>/ngx-tree-select.rollup.umd.min.js'
}

Otherwise if serving from node_modulesdirectly:

map: {
   ...
   'ngx-tree-select': 'node_modules/ngx-tree-select/bundles/ngx-tree-select.umd.min.js'
}

And in our packages property:

packages: {
   ...
  'ngx-tree-select': {
    main: 'index.js',
    defaultExtension: 'js'
  }

}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].