forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to EuiTableOfRecords documentation (#1)
* Add ability to toggle on and off different features of the table. * Rename ValueRenderers to EuiValueRenderers. * Add 'Column render types' example. * Hide footer when missing necessary config. Rename key prop to id. * Refer to dataType instead of renderType. * Rename column.id -> column.field.
- Loading branch information
Showing
11 changed files
with
266 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
import { times } from 'lodash'; | ||
|
||
import { | ||
EuiTableOfRecords, | ||
} from '../../../../src/components'; | ||
|
||
const selectRandom = (...array) => { | ||
const i = Math.floor(Math.random() * array.length); | ||
return array[i]; | ||
}; | ||
|
||
const records = times(5, (index) => { | ||
return { | ||
id: index, | ||
string: selectRandom('Martijn', 'Elissa', 'Clinton', 'Igor', 'Karl', 'Drew', 'Honza', 'Rashid', 'Jordan'), | ||
number: Math.floor(Math.random() * 20000), | ||
boolean: selectRandom(true, false), | ||
date: new Date( | ||
1990 + Math.floor(Math.random() * (1990 - 1971)), // year | ||
Math.floor(Math.random() * 12), // month | ||
Math.floor(Math.random() * 28), // day | ||
0, 0, 0, 0 | ||
), | ||
}; | ||
}); | ||
|
||
export default class extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.data = { | ||
records, | ||
totalRecordCount: records.length, | ||
}; | ||
} | ||
|
||
render() { | ||
const config = { | ||
recordId: 'id', | ||
columns: [ | ||
{ | ||
field: 'string', | ||
name: 'string', | ||
dataType: 'string', | ||
}, | ||
{ | ||
field: 'number', | ||
name: 'number', | ||
dataType: 'number' | ||
}, | ||
{ | ||
field: 'boolean', | ||
name: 'boolean', | ||
dataType: 'boolean' | ||
}, | ||
{ | ||
field: 'date', | ||
name: 'date', | ||
dataType: 'date' | ||
}, | ||
], | ||
}; | ||
|
||
const model = { | ||
data: this.data, | ||
}; | ||
|
||
return ( | ||
<EuiTableOfRecords config={config} model={model} /> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.