angular4-material-table
Version:
Angular 4 table based on @angular/cdk table structure, to allow row insertion, edition, validation and deletion.
66 lines (65 loc) • 2.95 kB
TypeScript
import { DataSource } from '@angular/cdk/collections';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
import { TableElement } from './table-element';
import { ValidatorService } from './validator.service';
export declare class TableDataSource<T> extends DataSource<TableElement<T>> {
private validatorService;
private rowsSubject;
datasourceSubject: Subject<T[]>;
private dataConstructor;
private dataKeys;
/**
* Creates a new TableDataSource instance, that can be used as datasource of `@angular/cdk` data-table.
* @param data Array containing the initial values for the TableDataSource. If not specified, then `dataType` must be specified.
* @param dataType Type of data contained by the Table. If not specified, then `data` with at least one element must be specified.
* @param validatorService Service that create instances of the FormGroup used to validate row fields.
*/
constructor(data: T[], dataType?: new () => T, validatorService?: ValidatorService);
/**
* Confirm edition of the row. Save changes and disable editing.
* If validation active and row data is invalid, it doesn't confirm editing neither disable editing.
* @param row Row to be edited.
*/
confirmEdit(row: TableElement<T>): void;
/**
* Confirm creation of the row. Save changes and disable editing.
* If validation active and row data is invalid, it doesn't confirm creation neither disable editing.
* @param row Row to be confirmed.
*/
confirmCreate(row: TableElement<T>): void;
/**
* Start the creation of a new element, pushing an empty-data row in the table.
*/
createNew(): void;
/**
* Delete the row with the index specified.
*/
delete(id: number): void;
/**
* Get the data from the rows.
* @param rows Rows to extract the data.
*/
getDataFromRows(rows: TableElement<T>[]): T[];
/**
* Update the datasource with the data contained in the specified rows.
* @param rows Rows that contains the datasource's new data.
*/
updateDatasource(rows: TableElement<T>[]): void;
/**
* From an array of data, it returns rows containing the original data.
* @param data Data from which create the rows.
*/
getRowsFromData(data: T[]): TableElement<T>[];
/**
* Create a new object with identical structure than the table source data.
* It uses the object's type contructor if available, otherwise it creates
* an object with the same keys of the first element contained in the original
* datasource (used in the constructor).
*/
createNewObject(): any;
/** Connect function called by the table to retrieve one stream containing
* the data to render. */
connect(): Observable<TableElement<T>[]>;
disconnect(): void;
}