我正在尝试使用jquery-treegrid在angular 2中制作树表。1.我在package.json上添加了一个jquery-treegrid依赖。2.安装typescript jquery库: tsd Install jquery 3.添加html代码:
<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>我的组件类:
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);
}
}控制台中的错误:
TypeError: this.rootNode.nativeElement.find is not a function我在这个论坛上关注了答案,但它不起作用。有没有其他插件可以在angular2中运行表树?
https://stackoverflow.com/questions/38458902
复制相似问题