Skip to content

Commit

Permalink
table bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NishiPhalke committed Oct 26, 2022
1 parent 21e8215 commit cb33f72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.4",
"version": "0.6.5",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
11 changes: 7 additions & 4 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ const CustomizedTable:React.FC<CustomizedTableProps> = (props) => {
};

let rows = props.tabledata;
console.log(rows)
console.log(rows
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage))
return (
<>
<TableContainer>
<Table stickyHeader aria-label="sticky table" >
<TableHead >
<TableRow>
{props.tabledata[0].map(t=>{
return <TableCell key={t.header} style={{textAlign:"center", fontWeight: "bold" ,border:"None"}}>{t.header}</TableCell>
{props.tabledata[0].map((t,k)=>{
return <TableCell key={t.header+k} style={{textAlign:"center", fontWeight: "bold" ,border:"None"}}>{t.header}</TableCell>
})}
</TableRow>
</TableHead>
Expand All @@ -56,8 +59,8 @@ const CustomizedTable:React.FC<CustomizedTableProps> = (props) => {
.map((row,i) => {
return(
<StyledTableRow key={i}>
{row.map(v=>{
return <StyledTableCell key={v.value}> { v.render ? v.render : v.value}</StyledTableCell>
{row.map((v,j)=>{
return <StyledTableCell key={i+j+v.value}> { v.render ? v.render : v.value}</StyledTableCell>
})
}
</StyledTableRow>
Expand Down
2 changes: 1 addition & 1 deletion stories/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Table = Template.bind({ });

const tdata = Array.from(Array(1000).keys()).map((a)=> {
//return { Symbol: 'S'+ a, 'Score 1':a, 'Score 2':1,'Score 3':4,'Score 4':6,'Score 5':9,'Score 6':0,'Score 7':9,'Score 8':1,'Score 9':2,'Score 10':5,'Score 11':12}
return [{header: 'Symbol', value: a},{ header: 'Score', value: 'score '+ a, render: <b>{'test'+a}</b>}]
return [{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 1', value: 'ss '+a},{header: 'Symbol 2', value: a},{header: 'Symbol 3', value: a},{header: 'Symbol 4', value: a},{ header: 'Score', value: 'score '+ a, render: <b>{'test'+a}</b>}]
})

Table.args = { rowsPerPage: [10,100], tabledata: tdata};
Expand Down

0 comments on commit cb33f72

Please sign in to comment.