首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular2中的表树

angular2中的表树
EN

Stack Overflow用户
提问于 2016-07-19 20:40:58
回答 0查看 636关注 0票数 1

我正在尝试使用jquery-treegrid在angular 2中制作树表。1.我在package.json上添加了一个jquery-treegrid依赖。2.安装typescript jquery库: tsd Install jquery 3.添加html代码:

代码语言:javascript
复制
  <table class="tree">
    <tr class="treegrid-1">
      <td>Root node</td><td>Additional info</td>
    </tr>
    <tr class="treegrid-2 treegrid-parent-1">
      <td>Node 1-1</td><td>Additional info</td>
    </tr>
    <tr class="treegrid-3 treegrid-parent-1">
      <td>Node 1-2</td><td>Additional info</td>
    </tr>
    <tr class="treegrid-4 treegrid-parent-3">
      <td>Node 1-2-1</td><td>Additional info</td>
    </tr>
  </table>

我的组件类:

代码语言:javascript
复制
declare var jQuery:any;
@Component({
  selector: '[configuration]',
  template: require('./configuration.html'),
  encapsulation: ViewEncapsulation.None,
  styles: [require('./configuration.scss')],
  directives: [Widget, TablesBackgrid, DataTableDirectives],
  providers: [ConfigurationService,
              HTTP_PROVIDERS],
  pipes: [SearchPipe]
})
export class Configuration implements AfterViewInit, OnInit {
  data: ISystem[];
  errorMessage: string;

  constructor(private configurationService: ConfigurationService, private rootNode: ElementRef) {
  }

  ngAfterViewInit() {
    jQuery(this.rootNode.nativeElement.find('.tree')[0]).treegrid();
  }

  ngOnInit(): void {
    this.configurationService.getSystems()
      .subscribe(systems => this.data = systems,
       error => this.errorMessage = <any>error);
  }

}

控制台中的错误:

代码语言:javascript
复制
TypeError: this.rootNode.nativeElement.find is not a function

我在这个论坛上关注了答案,但它不起作用。有没有其他插件可以在angular2中运行表树?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38458902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档