/
grid-core.jsx
62 lines (58 loc) · 1.93 KB
/
grid-core.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import PropTypes from 'prop-types';
import { PluginContainer, Getter, Template, TemplatePlaceholder } from '@devexpress/dx-react-core';
import { rowIdGetter, cellValueGetter } from '@devexpress/dx-grid-core';
export class GridCore extends React.PureComponent {
render() {
const {
rows,
columns,
getRowId,
getCellValue,
rootComponent: Root,
headerPlaceholderComponent: HeaderPlaceholder,
footerPlaceholderComponent: FooterPlaceholder,
} = this.props;
return (
<PluginContainer>
<Getter name="rows" value={rows} />
<Getter name="getRowId" value={rowIdGetter(getRowId, rows)} />
<Getter name="columns" value={columns} />
<Getter name="getCellValue" value={cellValueGetter(getCellValue, columns)} />
<Template name="header" />
<Template name="body" />
<Template name="footer" />
<Template name="root">
<Root>
<TemplatePlaceholder name="header">
{content => (HeaderPlaceholder
? <HeaderPlaceholder>{content}</HeaderPlaceholder>
: content)}
</TemplatePlaceholder>
<TemplatePlaceholder name="body" />
<TemplatePlaceholder name="footer">
{content => (FooterPlaceholder
? <FooterPlaceholder>{content}</FooterPlaceholder>
: content)}
</TemplatePlaceholder>
</Root>
</Template>
</PluginContainer>
);
}
}
GridCore.propTypes = {
rows: PropTypes.array.isRequired,
getRowId: PropTypes.func,
getCellValue: PropTypes.func,
columns: PropTypes.array.isRequired,
rootComponent: PropTypes.func.isRequired,
headerPlaceholderComponent: PropTypes.func,
footerPlaceholderComponent: PropTypes.func,
};
GridCore.defaultProps = {
getRowId: null,
getCellValue: null,
headerPlaceholderComponent: null,
footerPlaceholderComponent: null,
};