src/table/table-item.class.ts
Properties |
constructor(rawData?: any)
|
||||||||
|
Defined in src/table/table-item.class.ts:69
|
||||||||
|
Creates an instance of TableItem.
Parameters :
|
| data |
data:
|
Type : any
|
|
Defined in src/table/table-item.class.ts:12
|
|
Data for the table item. |
| expandedData |
expandedData:
|
Type : any
|
|
Defined in src/table/table-item.class.ts:22
|
|
Data for the expanded part of the row. You only need to set it for the first item in the row. |
| expandedTemplate |
expandedTemplate:
|
Type : TemplateRef<any>
|
|
Defined in src/table/table-item.class.ts:69
|
|
Template for rendering You only need to set it for the first item in the row. |
| template |
template:
|
Type : TemplateRef<any>
|
|
Defined in src/table/table-item.class.ts:59
|
|
Used to display data in a desired way. If not provided, displays data as a simple string. Usage: In a component where you're using the table create a template like: where we assume your data contains Create Set the template to the table item, for example: |
import {
TemplateRef
} from "@angular/core";
export class TableItem {
/**
* Data for the table item.
*
* @type {*}
* @memberof TableItem
*/
data: any;
/**
* Data for the expanded part of the row.
*
* You only need to set it for the first item in the row.
*
* @type {*}
* @memberof TableItem
*/
expandedData: any;
/**
* Used to display data in a desired way.
*
* If not provided, displays data as a simple string.
*
* Usage:
*
* In a component where you're using the table create a template like:
*
* ```html
* <ng-template #customItemTemplate let-data="data">
* <i><a [routerLink]="data.link">{{data.name}}</a></i>
* </ng-template>
* ```
* where we assume your data contains `link` and `name`. `let-data="data"` is
* necessary for you to be able to access item's data in the template.
*
* Create `ViewChild` property with:
*
* ```typescript
* (at)ViewChild("customItemTemplate")
* private customItemTemplate: TemplateRef<any>;
* ```
*
* Set the template to the table item, for example:
*
* ```typescript
* this.model.data = [
* [new TableItem({data: {name: "Custom item", link: "/table"}, template: this.customItemTemplate})]
* ];
* ```
*
* @type {TemplateRef<any>}
* @memberof TableItem
*/
template: TemplateRef<any>;
/**
* Template for rendering `expandedData`
*
* You only need to set it for the first item in the row.
*
* @type {TemplateRef<any>}
* @memberof TableItem
*/
expandedTemplate: TemplateRef<any>;
/**
* Creates an instance of TableItem.
* @param {*} [rawData]
* @memberof TableItem
*/
constructor(rawData?: any) {
// defaults so we dont leave things empty
const defaults = {
data: ""
};
// fill our object with provided props, and fallback to defaults
const data = Object.assign({}, defaults, rawData);
this.data = data.data;
this.expandedData = data.expandedData;
this.template = data.template;
this.expandedTemplate = data.expandedTemplate;
}
}