angular2-data-table
Version:
angular2-data-table is a Angular2 component for presenting large and complex data.
82 lines (68 loc) • 2.19 kB
text/typescript
import { Component } from '@angular/core';
@Component({
selector: 'tabs-demo',
template: `
<div>
<h3>Hidden By Default</h3>
<div style="width:75%;margin:0 auto">
<div>
<button type="button" (click)="tab1=true;tab2=false;tab3=false;">Nothing</button>
<button type="button" (click)="tab2=true;tab1=false;tab3=false;">Hidden</button>
<button type="button" (click)="tab3=true;tab1=false;tab2=false;">NgIf</button>
</div>
<div [hidden]="!tab1">
<p>Click a button to toggle table visibilities</p>
</div>
<div [hidden]="!tab2">
<h4>hidden Table</h4>
<swui-datatable
class='material'
[rows]='rows'
[columnMode]="'force'"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="50"
[scrollbarV]="true">
<swui-datatable-column name="Name" width="200"></swui-datatable-column>
<swui-datatable-column name="Gender" width="300"></swui-datatable-column>
<swui-datatable-column name="Age" width="80"></swui-datatable-column>
</swui-datatable>
</div>
<div *ngIf="tab3">
<h4>ngIf Table</h4>
<swui-datatable
class='material'
[rows]='rows'
[columnMode]="'force'"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="50"
[scrollbarV]="true">
<swui-datatable-column name="Name" width="200"></swui-datatable-column>
<swui-datatable-column name="Gender" width="300"></swui-datatable-column>
<swui-datatable-column name="Age" width="80"></swui-datatable-column>
</swui-datatable>
</div>
</div>
</div>
`
})
export class TabsDemoComponent {
rows = [];
tab1 = true;
tab2 = false;
tab3 = false;
constructor() {
this.fetch((data) => {
this.rows = data;
});
}
fetch(cb) {
let req = new XMLHttpRequest();
req.open('GET', `assets/data/100k.json`);
req.onload = () => {
cb(JSON.parse(req.response));
};
req.send();
}
}