Skip to content

Commit b4f4f9c

Browse files
authored
Merge pull request #50 from ShlomoPorges/development
TableGrid work
2 parents 65e1ff0 + 740d94d commit b4f4f9c

File tree

4 files changed

+47
-37
lines changed

4 files changed

+47
-37
lines changed

src/components/DataTable.jsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import TableHead from '@material-ui/core/TableHead';
88
import TableRow from '@material-ui/core/TableRow';
99
import Paper from '@material-ui/core/Paper';
1010
import Button from '@material-ui/core/Button';
11+
import DeleteIcon from '@material-ui/icons/Delete';
12+
import { IconButton } from '@material-ui/core';
13+
1114

1215
const styles = theme => ({
1316
root: {
@@ -16,7 +19,7 @@ const styles = theme => ({
1619
overflowX: 'auto',
1720
},
1821
table: {
19-
minWidth: 700,
22+
minWidth: 500,
2023
},
2124
});
2225

@@ -38,26 +41,33 @@ function dataTable(props) {
3841
if (!row) return;
3942
// for some reason we must put each value in a div.
4043
return rowHeader.map((header, idx) => (
41-
<TableCell key={`td_${idx}`}>
42-
<div>{typeof row[header] === 'string' ? row[header] : row[header].toString()}</div>
44+
<TableCell align={'center'} key={`td_${idx}`}>
45+
{/* <div align={'center'} padding = {'none'} >{typeof row[header] === 'string' ? row[header] : row[header].toString()}</div> */}
46+
{/* {row[header]} */}
47+
{typeof row[header] === 'string' ? row[header] : row[header].toString()}
4348
</TableCell>
4449
));
4550
}
46-
51+
//style={{height: 30}}
4752
const renderRows = rowData.map(row => (
4853
<TableRow key={`row-${row.id}`}>
4954
{renderRowCells(row)}
50-
<TableCell>
51-
<Button onClick={() => deletePropHandler(row.id)}>Delete</Button>
55+
<TableCell align={'center'} padding = {'none'} >
56+
<IconButton color="default" fontSize="small" onClick={() => deletePropHandler(row.id)} >
57+
<DeleteIcon/>
58+
</IconButton>
59+
{/* <Button style={{height: 20}} onClick={() => deletePropHandler(row.id)}>Delete</Button> */}
5260
</TableCell>
5361
</TableRow>
5462
));
5563

5664
return (
5765
<Paper className={classes.root}>
58-
<Table className={classes.table}>
66+
<Table className={classes.table}
67+
selectable = {"true"}
68+
>
5969
<TableHead>
60-
<TableRow>{renderHeader}</TableRow>
70+
<TableRow >{renderHeader}</TableRow>
6171
</TableHead>
6272
<TableBody>{renderRows}</TableBody>
6373
</Table>

src/components/LeftColExpansionPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const LeftColExpansionPanel = props => {
3434
.join(",");
3535

3636
function isFocused() {
37-
return focusComponent.title === title ? "focused" : "";
37+
return focusComponent.id == id ? "focused" : "";
3838
}
3939

4040
return (

src/components/Props.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ class Props extends Component {
177177
) : (
178178
<Fragment>
179179
<div className="props-container">
180-
<Grid container spacing={16}>
181-
<Grid item xs={5}>
180+
<Grid container spacing={8}>
181+
<Grid item xs={4}>
182182
<form className="props-input" onSubmit={this.handleAddProp}>
183-
<Grid container spacing={24}>
183+
<Grid container spacing={8}>
184184
<Grid item xs={6}>
185185
<TextField
186186
id="propKey"
@@ -260,7 +260,7 @@ class Props extends Component {
260260
</Grid>
261261
</form>
262262
</Grid>
263-
<Grid item xs={11}>
263+
<Grid item xs={8}>
264264
<DataTable
265265
rowHeader={rowHeader}
266266
rowData={propsRows}

src/components/TableGrid.jsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import React from 'react';
2-
import ReactDataGrid from 'react-data-grid';
1+
// import React from 'react';
2+
// import ReactDataGrid from 'react-data-grid';
33

4-
function DataGrid() {
5-
const columns = [
6-
{ key: 'idd', name: 'ID' },
7-
{ key: 'title', name: 'Title' },
8-
{ key: 'count', name: 'Count' },
9-
];
4+
// function DataGrid() {
5+
// const columns = [
6+
// { key: 'idd', name: 'ID' },
7+
// { key: 'title', name: 'Title' },
8+
// { key: 'count', name: 'Count' },
9+
// ];
1010

11-
const rows = [
12-
{ idd: 0, title: 'row1', count: 20 },
13-
{ idd: 1, title: 'row1', count: 40 },
14-
{ idd: 2, title: 'row1', count: 60 },
15-
];
11+
// const rows = [
12+
// { idd: 0, title: 'row1', count: 20 },
13+
// { idd: 1, title: 'row1', count: 40 },
14+
// { idd: 2, title: 'row1', count: 60 },
15+
// ];
1616

17-
// console.log(`ract data grid: rows`)
18-
// console.log(rows)
19-
// console.log(`ract data grid: columns`)
20-
// console.log(columns)
17+
// // console.log(`ract data grid: rows`)
18+
// // console.log(rows)
19+
// // console.log(`ract data grid: columns`)
20+
// // console.log(columns)
2121

22-
function getRow(i) {
23-
console.log(`i=${i} rows{i}= ${rows[i]}`);
24-
return rows[i];
25-
}
22+
// function getRow(i) {
23+
// console.log(`i=${i} rows{i}= ${rows[i]}`);
24+
// return rows[i];
25+
// }
2626

27-
return <ReactDataGrid columns={columns} rowGetter={i => rows[i]} rowsCount={2} minHeight={200} />;
28-
}
27+
// return <ReactDataGrid columns={columns} rowGetter={i => rows[i]} rowsCount={2} minHeight={200} />;
28+
// }
2929

30-
export default DataGrid;
30+
// export default DataGrid;

0 commit comments

Comments
 (0)