【发布时间】:2017-11-02 19:09:47
【问题描述】:
To create a table using ng-table in Angular 2 is simple however now I want to input checkbox column in the front of the table so that whenever a particular row is selected, its data would be selected too.
Table.html 包含
<ng-table [config]="config"
(tableChanged)="onChangeTable(config)"
(cellClicked)="onCellClick($event)"
[rows]="rows" [columns]="columns">
</ng-table>
Table.ts 包含
@Component({
moduleId: module.id,
selector: 'table',
templateUrl: 'table.component.html',
styleUrls: ['table.component.css']
})
export class TableComponent implements OnInit {
public rows:Array<any> = [];
public columns:Array<any> = [
{title: 'Fruits', name: 'Description', filtering: {filterString: '', placeholder: 'Filter by description'}},
{title: 'Colour', name: 'Colour', sort: '', filtering: {filterString: '', placeholder: 'Filter by colour'}},
{title: 'Size', name: 'Size'}
];
public config:any = {
paging: true,
sorting: {columns: this.columns},
filtering: {filterString: ''},
className: ['table-striped', 'table-bordered']
};
我对如何在此表中实现复选框功能感到困惑。如果您能分享一些关于 Angular 2 的知识,我们将不胜感激。
【问题讨论】:
-
你知道如何做到这一点吗?