test and doc generateSchema

This commit is contained in:
Eugenio Romano
2016-07-19 10:21:22 +01:00
parent c86e23351c
commit beb37a2ded
4 changed files with 63 additions and 12 deletions

View File

@@ -32,22 +32,26 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
private _rows: DataRow[];
private _columns: DataColumn[];
static generateSchema(rowToExaminate: any) {
static generateSchema(data: any[]) {
let schema = [];
if (typeof rowToExaminate === 'object') {
for (let key in rowToExaminate) {
if (rowToExaminate.hasOwnProperty(key)) {
schema.push({
type: 'text',
key: key,
title: key,
sortable: false
});
if (data && data.length) {
let rowToExaminate = data[0];
if (typeof rowToExaminate === 'object') {
for (let key in rowToExaminate) {
if (rowToExaminate.hasOwnProperty(key)) {
schema.push({
type: 'text',
key: key,
title: key,
sortable: false
});
}
}
}
}
}
return schema;
}