Giter Site home page Giter Site logo

cipchk / ng-tree-antd Goto Github PK

View Code? Open in Web Editor NEW
67.0 5.0 11.0 1.46 MB

A antd style of based on angular-tree-component.

Home Page: https://cipchk.github.io/ng-tree-antd/

License: MIT License

JavaScript 6.23% TypeScript 16.95% CSS 76.30% HTML 0.52%
angular-tree ng-tree-antd ngx-tree ng2-tree angular ng-zorro-antd

ng-tree-antd's Introduction

项目不会再发布兼容 ng-zorro-antd 0.7.0 版本,已经内置 nz-tree 组件;0.6.x 之前的依然可用。

ng-tree-antd

A antd style of based on angular-tree-component.

NPM version Build Status

Demo

Live Demo & stackblitz

Dependencies

  • angular-tree-component ^7.0.1

Usage & Installation

Install ng-tree-antd from npm

npm install ng-tree-antd --save

Import the NzTreeModule in to your root AppModule.

import { NzTreeModule } from 'ng-tree-antd';
import { NgZorroAntdModule } from 'ng-zorro-antd';

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

Usage

import { Component } from '@angular/core';
import { generateData } from './generate-data';

@Component({
  selector: 'demo',
  template: `
  <nz-tree [nzNodes]="nodes"
           [nzOptions]="options"
           (nzEvent)="onEvent($event)"></nz-tree>
  `
})
export class DemoDraggableComponent {
  nodes = [
    {
      name: 'root1'
    },
    {
      name: 'root2'
    },
    {
      name: 'root3'
    },
    {
      name: 'async root4',
      hasChildren: true
    }
  ];

  options = {
    allowDrag: true
  };

  onEvent(ev: any) {
    console.log('onEvent', ev);
  }
}

nzNodes DATA

the nzNodes is array of the tree, and each node may contain the following fileds:

  • id unique id
  • name default displayed filed, you can setting displayField of options property
  • checked specifies whether the checkbox is selected
  • disableCheckbox disable checkbox
  • halfChecked achieve a 'check all' effect
  • children an array of the node's children.
  • hasChildren for async data load, so you need setting getChildren of options property

API

Name Type Default Summary
nzNodes any[] see inputs
nzAutoExpandParent boolean, number false 是否自动展开父节点,当数字时展开最大节点
nzAllowChildLinkage boolean true 是否开启父节点的checkbox状态的会影响子节点状态
nzAllowParentLinkage boolean true 是否开启子节点的checkbox状态的会影响父节点状态
nzCheckable boolean false Add a checkbox before the node
nzShowLine boolean false Shows a connecting line
nzOptions TreeOptions see options
nzTitle TemplateRef Custom title
nzLoading TemplateRef Custom Loading
nzShiftSelectedMulti boolean true selected multi when shift key
nzToggleExpanded EventEmitter see events
nzActivate EventEmitter
nzDeactivate EventEmitter
nzFocus EventEmitter
nzBlur EventEmitter
nzUpdateData EventEmitter
nzInitialized EventEmitter
nzMoveNode EventEmitter
nzCopyNode EventEmitter
nzLoadNodeChildren EventEmitter
nzChangeFilter EventEmitter
nzEvent EventEmitter
nzStateChange EventEmitter
nzCheck EventEmitter fired checkbox is changed

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

ng-tree-antd's People

Contributors

cipchk avatar mo-gong avatar ng2tech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ng-tree-antd's Issues

TypeError: Object(...) is not a function

ERROR TypeError: angularTreeComponent.TREE_ACTIONS.TOGGLE_ACTIVE is not a function

NzTreeComponent.html:42 ERROR TypeError: angularTreeComponent.TREE_ACTIONS.TOGGLE_ACTIVE is not a function
at click (ng-tree-antd.umd.js:108)
at TreeNode.mouseAction (tree-node.model.js:366)
at Object.eval [as handleEvent] (NzTreeComponent.html:46)
at handleEvent (core.js:13581)
at callWithDebugContext (core.js:15090)
at Object.debugHandleEvent [as handleEvent] (core.js:14677)
at dispatchEvent (core.js:9990)
at eval (core.js:10611)
at HTMLSpanElement.eval (platform-browser.js:2628)
at ZoneDelegate.invokeTask (zone.js:421)

初始化时,不能自动多级勾选

默认加载时,只能自动勾选上一级的checkbox状态,如果有多级,则不能勾选到更上一级,有解决方案吗?

可以提供checked三个状态值吗?现在只有true,false .

001

在IE11下会报错

ERROR Error: Uncaught (in promise): Error: [mobx] MobX 5+ requires Proxy objects. If your environment doesn't support Proxy objects, please downgrade to MobX 4.

目前2.2.3遇到问题。报了“ngDevMode”错误

ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/ng-tree-antd/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.

我暂时锁到2.0.0版本,没有报错。

ng-tree-antd在angularjs4.4.6出现错误

环境:
"angular-tree-component": "^5.1.2",
"ng-zorro-antd": "^0.6.0-rc.2",
"ng-tree-antd": "^1.0.0",

已在AppModule引入NzTreeModule

使用nz-tree组件:
<nz-tree [nzNodes]="nodes" [nzShowLine]="true" (nzEvent)="onEvent($event)">

编译可以通过,浏览器控制台出现:

Uncaught Error: Template parse errors:
Can't bind to 'nzNodes' since it isn't a known property of 'nz-tree'.
1. If 'nz-tree' is an Angular component and it has 'nzNodes' input, then verify that it is part of this module.
2. If 'nz-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<nz-tree [ERROR ->][nzNodes]="nodes" [nzShowLine]="true" (nzEvent)="onEvent($event)"></nz-tree>"): ng:///HomeRoutingModule/OrganComponent.html@0:9
Can't bind to 'nzShowLine' since it isn't a known property of 'nz-tree'.
1. If 'nz-tree' is an Angular component and it has 'nzShowLine' input, then verify that it is part of this module.
2. If 'nz-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<nz-tree [nzNodes]="nodes" [ERROR ->][nzShowLine]="true" (nzEvent)="onEvent($event)"></nz-tree>"): ng:///HomeRoutingModule/OrganComponent.html@0:27
'nz-tree' is not a known element:
1. If 'nz-tree' is an Angular component, then verify that it is part of this module.
2. If 'nz-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<nz-tree [nzNodes]="nodes" [nzShowLine]="true" (nzEvent)="onEvent($event)"></nz-tree>"): ng:///HomeRoutingModule/OrganComponent.html@0:0

angular5 --prod

ERROR in Error at /Users/hanzhendong/workspace/web/angular-webapp/pclearner/node_modules/ng-tree-antd/components/nz-tree.component.d.ts.NzTreeComponent.html(59,13): ("
<ng-container
[ngTemplateOutlet]="nzTitle"
[ERROR ->][ngOutletContext]="{ $implicit: node, node: node, index: index }">

")

angular5 ng build --prod

ng build -prod fail

$ ng build -prod

ERROR in ..\ng-tree-antd\index.ts(10,2): Error during template compile of 'NzTreeModule'
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'NgModule'
'NgModule' calls 'ɵmakeDecorator'.

初始化时不能勾选父节点状态

this.nodes = [
      {
        name: '账户',
        hasChildren: true,
        checked: false,
        children: [
            {
              id: 1,
              name: 'name1',
              checked: false
            },
            {
              id: 2,
              name: 'name2',
              checked: true
            }
        ]
      }
    ]

期望的是
image

现在页面展示是
image

请问有好的解决方案吗

菜单的icon问题

看ng-alain项目里面有好几个icon库,但是simple-line-icons可以显示在menu的左边,用antd自带的icon不会显示在菜单旁

macOS下的 Safari 浏览器报错

错误信息为:The only valid numeric escape in strict mode is '\0', and this must not be followed by a decimal digit.

Angular 已经不支持 IE6IE8,因此,使用 "\9" 这样的 hack 去区别并兼容 IE7IE8 的样式已经没有必要了。反而这个 "\9" 在Safari浏览下面会引起字符串解析的Exception。

Top level remains intermedian status when execute specify operation

There are 3 levels menu. Do the operations:

  • Check the third level (the path is intermedian, the item is checked)
  • Check the top level (all items are checked)
  • Uncheck the top level

expect all items are unchecked but the top remains intermedian.

I found everything OK in angular-tree-component demo page.

A gif explains the operations:
ng-tree-antd_bug

关于自定义图标

你好,我查了angular2-tree关于自定义图标,有人说用custom template可以,https://angular2-tree.readme.io/discuss/58945fe1f4de7c1b003265bb

我在nztree上试了下 不生效,看源代码发现nztree封装了ng-template,这是不是以为这我不能在nztree上使用ng-template了。

我的需求是在node上带一个属性,然后根据属性应用不同的font-icon来显示图标。

谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.