angular2-data-table
Version:
angular2-data-table is a Angular2 component for presenting large and complex data.
102 lines (87 loc) • 2.44 kB
text/typescript
import { Component } from '@angular/core';
export class CheckboxSelectionComponent {
rows = [];
selected = [];
constructor() {
this.fetch((data) => {
this.rows = data;
});
}
fetch(cb) {
const req = new XMLHttpRequest();
req.open('GET', `assets/data/company.json`);
req.onload = () => {
cb(JSON.parse(req.response));
};
req.send();
}
onSelect({ selected }) {
console.log('Select Event', selected, this.selected);
this.selected.splice(0, this.selected.length);
this.selected.push(...selected);
}
onActivate(event) {
console.log('Activate Event', event);
}
add() {
this.selected.push(this.rows[1], this.rows[3]);
}
update() {
this.selected = [ this.rows[1], this.rows[3] ];
}
remove() {
this.selected = [];
}
}