javascript-在angular 6中制作动态可配置表的最佳方法是什么?
作者:互联网
谁能建议在网站上制作动态表格的最佳方法?我希望该表是可配置的.
解决方法:
这是我写的表格组件
https://stackblitz.com/edit/angular-xdn6nq
要使用它,您可以给它一个数据数组和一个TableConfig对象.
<app-table [data]="data" [config]="tableConfig"></app-table>
表配置对象具有接口
interface TableConfig {
columns: ColumnConfig<any>[];
columnGroups?: ColumnGroup[];
filters?: ((item: any) => boolean)[];
groupBy?: GroupBy;
update?: Subject<boolean>;
}
Columns是您将要设置的主要属性,它是ColumnConfig的数组,具有接口
interface ColumnConfig<T> {
property: string;
type?: ColumnType;
heading?: string;
sortable?: boolean;
direction?: ColumnSortDirection;
compare?: (a: T, b: T) => number; // Return -1 if a is less than b by some ordering criterion, 0 if equal, 1 a is greater than b by the ordering criterion
display?: (item: T) => string;
route?: (item: T) => string;
href?: (item: T) => string;
}
标签:html,javascript,angular6 来源: https://codeday.me/bug/20191024/1923289.html