Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ngx-treeview-v2
Advanced tools
An Angular treeview component with checkbox
Leo Vo leovo2708@gmail.com
Varun P varunp5814@gmail.com
This component is currently supporting Bootstrap 4. If you are using Bootstrap 4 alpha 6, please downgrade to the older version 1.0.10.
You can customize CSS yourself to break down dependencies to Bootstrap.
https://leovo2708.github.io/ngx-treeview/
After install the above dependencies, install ngx-treeview-v2
via:
npm install ngx-treeview --save
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 {
}
<ngx-treeview
[config]="config"
[items]="items"
(selectedChange)="onSelectedChange($event)"
(filterChange)="onFilterChange($event)"
>
</ngx-treeview>
<ngx-dropdown-treeview
[buttonClass]="buttonClass"
[config]="config"
[items]="items"
(selectedChange)="onSelectedChange($event)"
(filterChange)="onFilterChange($event)"
>
</ngx-dropdown-treeview>
config
is optional. This is the default configuration:
{
hasAllCheckBox: true,
hasFilter: false,
hasCollapseExpand: false,
decoupleChildFromParent: false,
maxHeight: 500
}
You can change default configuration easily because TreeviewConfig is injectable.
ngxTreeview
:To map your JSON objects to TreeItem objects.
<ngx-dropdown-treeview
[config]="config"
[items]="items | ngxTreeview:'textField'"
(selectedChange)="onSelectedChange($event)"
>
</ngx-dropdown-treeview>
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 },
],
},
],
});
You can pass the second paramater 'autoCorrectChecked' with value=true (default is false) in constructor of TreeviewItem to correct checked value of it and all of its descendants. In some cases, you need to push or pop children flexibly, checked of parent may be not correct. Then you need to call function correctChecked() to help to correct from root to its descendants.
const vegetableCategory = new TreeviewItem({
text: "Vegetable",
value: 2,
children: [
{ text: "Salad", value: 21 },
{ text: "Potato", value: 22 },
],
});
vegetableCategory.children.push(
new TreeviewItem({ text: "Mushroom", value: 23, checked: false })
);
vegetableCategory.correctChecked(); // need this to make 'Vegetable' node to change checked value from true to false
Extract data from list of checked TreeviewItem and send it in parameter of event selectedChange. Some built-in TreeviewEventParser:
See example 4 & 5.
I am very appreciate for your ideas, proposals and found bugs which you can leave in github issues. Thanks in advance!
FAQs
An Angular treeview component with checkbox
The npm package ngx-treeview-v2 receives a total of 534 weekly downloads. As such, ngx-treeview-v2 popularity was classified as not popular.
We found that ngx-treeview-v2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.