Questions tagged [ngx-treeview]

ngx-treeview

An Angular treeview component with checkbox

Dependencies

You can customize CSS yourself to break down dependencies to Bootstrap & Font Awesome.

Features:

  • maxCount can select up to a few items
  • isShowTotal Checks the displayed result style type
  • Change the default checked to selected to unchecked
  • Change the default item to checked = true to false
  • Unlimited tree level
  • State: disabled / collapse, expand
  • Filtering
  • Internationalization (i18n) support
  • Template

Installation

After install the above dependencies, install ngx-treeview via:

npm install --save mizi-ngx-treeview

Once installed you need to import our main module in your application module:

import { TreeviewModule } from 'ngx-treeview';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [TreeviewModule.forRoot(), ...],  
  bootstrap: [AppComponent]
})
export class AppModule {
}

Usage

Treeview:

<ngx-treeview
    [config]="config"
    [items]="items"
    (selectedChange)="onSelectedChange($event)">
</ngx-treeview>
Treeview with dropdown:
<ngx-dropdown-treeview
    [config]="config"
    [items]="items"
    (selectedChange)="onSelectedChange($event)">
</ngx-dropdown-treeview>

config is optional. This is the default configuration:

{
   isShowAllCheckBox: true,
   isShowFilter: false,
   isShowCollapseExpand: false,
   maxHeight: 500,
   maxCount: 0,
   isShowTotal: true
}

You can change default configuration easily because TreeviewConfig is injectable.

Pipe ngxTreeview: To map your JSON objects to TreeItem objects.

<ngx-dropdown-treeview
    [config]="config"
    [items]="items | ngxTreeview:'textField'"
    (selectedChange)="onSelectedChange($event)">
</ngx-dropdown-treeview>  

Create a TreeviewItem:

const itCategory = new TreeviewItem({
   text: 'IT', value: 9, children: [
       {
           text: 'Programming', value: 91, children: [{
               text: 'Frontend', value: 911, children: [
                   { text: 'Angular 1', value: 9111 },
                   { text: 'Angular 2', value: 9112 },
                   { text: 'ReactJS', value: 9113 }
               ]
           }, {
               text: 'Backend', value: 912, children: [
                   { text: 'C#', value: 9121 },
                   { text: 'Java', value: 9122 },
                   { text: 'Python', value: 9123, checked: false }
               ]
           }]
       },
       {
           text: 'Networking', value: 92, children: [
               { text: 'Internet', value: 921 },
               { text: 'Security', value: 922 }
           ]
       }
   ]
});

TreeviewEventParser:

Extract data from list of checked TreeviewItem and send it in parameter of event selectedChange. Some built-in TreeviewEventParser:

  • DefaultTreeviewEventParser: return values of checked items.
  • DownlineTreeviewEventParser: return list of checked items in orginal order with their ancestors.
  • OrderDownlineTreeviewEventParser: return list of checked items in checked order with their ancestors. Note that: value of a leaf must be different from value of other leaves.

Refrence

22 questions
3
votes
0 answers

Limit Selection in ngx-treeview

I have worked on advanced treeview: After some changes I tried to limit selection number. However, I have faced couple of problems. I can limit my selection but I cannot remove check in checkbox when limit is exceed. Here is my work:
Süleyman K
  • 309
  • 1
  • 8
  • 17
2
votes
1 answer

angular 7 get Parent node value from ngx-treeview

I used angular 7 and ngx-treeview component . I have used a config of decoupleChildFromParent= true. From this treeview we only get child tree value. I want to get the parent node value. this my html code :
franco
  • 1,829
  • 6
  • 42
  • 75
2
votes
1 answer

ngx treeview select all children under one parent

In my Angular 5 application I'm using ngx treeview in a drop down. I want to add an icon to select children under one particular parent. Thanks in…
Prasanga
  • 1,008
  • 2
  • 15
  • 34
1
vote
1 answer

How to change placeholder in ngx-treeview

How can we change the placeholder of treeview, using an appropriate method providers: [ { provide: TreeviewI18n, useValue: Object.assign(new TreeviewI18nDefault(),{ getFilterPlaceholder(): string { return ' search Library ...'; } …
1
vote
0 answers

change text color of each item in treeview

I used angular 7 and ngx-treeview. I want to change text color of item if some condition is verified. this is my html file :
franco
  • 1,829
  • 6
  • 42
  • 75
1
vote
0 answers

angular 6 ngx-treeview custom styling

I am using ngx-treeview component in my angular 6 project. My tree-view items are very lengthy. So, I'm trying to apply text-overflow:ellipsis in the ./treeview-container .row-item. snippet goes like this :host /deep/ .treeview-container .row-item…
preethi
  • 11
  • 6
1
vote
1 answer

checked property is not setting to true inside treeviewitem of a filtered result in ngx-treeview component

My config: config = TreeviewConfig.create({ hasAllCheckBox: false, hasFilter: true, hasCollapseExpand: false, decoupleChildFromParent: true, maxHeight: 400 }); I am using the inbuilt filter to find specific items in tree structure. But when I am…
1
vote
0 answers

How to get last unchecked item in ngx-treeview?

I am using npm module named as ngx-treeview . In this I can get the all selected items on change but not that one specific item which is getting changed. I am looking for uncheck. In component.html file:
Deep Kakkar
  • 5,831
  • 4
  • 39
  • 75
1
vote
1 answer

select only parent node treeview in angular 4

i am working with ngx-treeview in angular 4. here i want only parent need to be select when i click on it.Picture so, how to achieve it
0
votes
1 answer

Using ngx-treeview Angular 16

I'm trying to migrate Angular from 12 version to 16 and I have a package ngx-treeview, last update was for 10 version but it was used for 12 as well but it doesn't work now at all. I have an error This likely means that the library (ngx-treeview)…
0
votes
1 answer

Angular ngx-treeview Styling

I am a bit new to Angular and HTML. I am using ngx-treeview library to my Angular project and I want to style it, but I don't know how. If someone could help me, I would appreciate it. I want to move arrow on the left.
Jimmy
  • 13
  • 5
0
votes
1 answer

ngx-treeview height should be same size as the browser and dynamic with browser size

config = TreeviewConfig.create({ hasAllCheckBox: false, hasFilter: true, hasCollapseExpand: false, decoupleChildFromParent: false, maxHeight: 600 }); **i am trying to make responsive ngx-treeview and its height should show as browser size only. if…
user15926273
0
votes
1 answer

Is there a way to clear the filter of ngx-treeview component?

I have a form which contains several fields, out of which the location is a tree view with filter. Whenever I am resetting the form, the entered filter value is not getting cleared. I haven't find any solutions from the publisher documents. Anyone…
0
votes
1 answer

Failed: Unexpected value 'TreeviewConfig' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation in unit test

I am trying to test a component containing ngx-treeview. I wrote the following test, but it fails with the error message contained in the title (obviously except the in unit test part): import { ComponentFixture, TestBed, waitForAsync } from…
Munchkin
  • 857
  • 5
  • 24
  • 51
0
votes
1 answer

How to parse my kind of response to a treeview structure required for ngx-treeview

I have the following response structure and I'm trying to either group or parse them to fit the ngx-treeview requesting data structure. Can somebody help me achieve it? { "@type": "QueryResult", "result": [ { "@type": "Folder", …
Akhil
  • 368
  • 4
  • 16
1
2