Skip to content

Commit

Permalink
Merge pull request #1366 from gregnb/v3_1_2
Browse files Browse the repository at this point in the history
version 3.1.2 (fixes)
  • Loading branch information
patorjk committed Jun 22, 2020
2 parents 0a6d2a1 + 996bf3a commit 8fb338e
Show file tree
Hide file tree
Showing 13 changed files with 500 additions and 111 deletions.
41 changes: 26 additions & 15 deletions examples/draggable-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
import TextField from '@material-ui/core/TextField';

import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';

function Example() {

const [responsive, setResponsive] = useState("vertical");
Expand All @@ -16,11 +19,20 @@ function Example() {
const [transitionTime, setTransitionTime] = useState(300);
const [selectableRows, setSelectableRows] = useState('none');

const columns = ["Name", "Title", "Location", {
const [treeData, setTreeData] = useState([
{ title: 'Chicken', children: [{ title: 'Egg' }] },
{ title: 'Fish', children: [{ title: 'fingerline'}] }
]);

const columns = [{
name: 'hidden',
options: {
display: 'excluded'
}
},"Name", "Title", "Location", {
name: 'No Drag',
options: {
draggable: false,
display: 'false'
}
}, "Phone"];

Expand All @@ -35,22 +47,21 @@ function Example() {
transitionTime
},
selectableRows: selectableRows,
resizableColumns: true,
};

const data = [
["Gabby George", "Business Analyst", "Minneapolis","1","555-1234"],
["Aiden Lloyd", "Business Consultant for an International Company and CEO of Tony's Burger Palace", "Dallas","2","555-1234"],
["Jaden Collins", "Attorney", "Santa Ana","1","555-5555"],
["Franky Rees", "Business Analyst", "St. Petersburg","1","555-3333"],
["Aaren Rose", null, "Toledo","1","555-4444"],
["Johnny Jones", "Business Analyst", "St. Petersburg","3","555-2468"],
["Jimmy Johns", "Business Analyst", "Baltimore","1","555-1357"],
["Jack Jackson", "Business Analyst", "El Paso","1","555-4321"],
["Joe Jones", "Computer Programmer", "El Paso","1","555-4321"],
["Jacky Jackson", "Business Consultant", "Baltimore","4","555-1234"],
["Jo Jo", "Software Developer", "Washington DC","4","555-1122"],
["Donna Marie", "Business Manager", "Annapolis","5","555-5555"],
["1","Gabby George", "Business Analyst", "Minneapolis","1","555-1234"],
["1","Aiden Lloyd", "Business Consultant for an International Company and CEO of Tony's Burger Palace", "Dallas","2","555-1234"],
["1","Jaden Collins", "Attorney", "Santa Ana","1","555-5555"],
["1","Franky Rees", "Business Analyst", "St. Petersburg","1","555-3333"],
["1","Aaren Rose", null, "Toledo","1","555-4444"],
["1","Johnny Jones", "Business Analyst", "St. Petersburg","3","555-2468"],
["1","Jimmy Johns", "Business Analyst", "Baltimore","1","555-1357"],
["1","Jack Jackson", "Business Analyst", "El Paso","1","555-4321"],
["1","Joe Jones", "Computer Programmer", "El Paso","1","555-4321"],
["1","Jacky Jackson", "Business Consultant", "Baltimore","4","555-1234"],
["1","Jo Jo", "Software Developer", "Washington DC","4","555-1122"],
["1","Donna Marie", "Business Manager", "Annapolis","5","555-5555"],

];

Expand Down
2 changes: 2 additions & 0 deletions examples/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Simple from './simple';
import SimpleNoToolbar from './simple-no-toolbar';
import TextLocalization from './text-localization';
import CustomComponents from './custom-components';
import InfiniteScrolling from './infinite-scrolling';
import Themes from './themes';
import LargeDataSet from './large-data-set';

Expand Down Expand Up @@ -58,6 +59,7 @@ export default {
'Expandable Rows': ExpandableRows,
'Fixed Header': FixedHeader,
'Hide Columns Print': HideColumnsPrint,
'Infinite Scrolling': InfiniteScrolling,
'Large Data Set': LargeDataSet,
'OnDownload': OnDownload,
'OnTableInit': OnTableInit,
Expand Down
189 changes: 189 additions & 0 deletions examples/infinite-scrolling/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import React, { Fragment, Component } from "react";
import { Waypoint } from "react-waypoint";
import PropTypes from "prop-types";
import MUIDataTable from "../../src/";
import { createMuiTheme, MuiThemeProvider } from "@material-ui/core/styles";
import {
withStyles,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Paper
} from "@material-ui/core";

const styles = theme => ({
root: {
width: "100%",
overflowX: "auto",
height: 300,
flexGrow: 1
},
head: {
backgroundColor: theme.palette.primary.main,
color: "#fff",
position: "sticky",
fontSize: ".6rem",
top: 0
},
table: {
minWidth: 700,
height: 200
},
tableCell: {
fontSize: ".6rem"
}
});

class MessageManager extends Component {
constructor(props) {
super(props);
this.props = props;

this.state = {
filteredMessages: []
};
}

componentDidMount() {
this.getMessages(0);
}

columns = [
{
name: "Id",
options: {
filter: false,
sort: false,
customBodyRenderLite: (dataIndex, rowIndex) => {
const { filteredMessages } = this.state;
let value = filteredMessages[dataIndex][0];

if (rowIndex === filteredMessages.length - 10) {
return (
<Fragment>
<Waypoint
onEnter={() => {
console.log("WAYPOINT REACHED");
const newData = this.buildTestData(
30,
filteredMessages.length
);

this.setState({
filteredMessages: [...filteredMessages, ...newData]
});
}}
/>
{value}*
</Fragment>
);
} else {
return <Fragment>{value}</Fragment>;
}
}
}
},
{
name: "Message",
options:{
sort: false,
}
},
{
name: "Requester",
options:{
sort: false,
}
}
];

options = {
filter: false,
fixedHeader: true,
filterType: "dropdown",
responsive: "standard",
selectableRows: "none",
pagination: false,
tableBodyHeight:'500px',
onRowClick(rowNode) {
console.log(rowNode);
}
};

/*eslint-disable */
buildTestData(count, startingIndex) {
const data = [
["Template 1", "Requester Jerry"],
["Template 2", "Test user 1"],
["Order66", "Test user 2"],
["Live Message", "Another Person"],
["Future Message", "John Doe"],
["Expired Message", "Jane Doe"],
["Retired Message", "Some Guy"]
];

function createData(id, message, requester) {
return [id, message, requester];
}

const rows = [];

for (let i = 0; i < count; i += 1) {
const randomSelection = data[Math.floor(Math.random() * data.length)];
const id = i + 1 + startingIndex;
rows.push(createData(id, ...randomSelection));
}
return rows;
}
/* eslint-enable */

getMessages(pageNum) {
const THIRTYROWS = 30;
const messages = this.buildTestData(THIRTYROWS, 0);
this.setState({
filteredMessages: messages
});
}

getMuiTheme = () =>
createMuiTheme({
typography: {
useNextVariants: true
},
overrides: {
MUIDataTable: {
root: {}
},
MUIDataTableBodyRow: {
root: {
"&:nth-child(odd)": {
backgroundColor: "#f6f6f6"
}
}
},
MUIDataTableBodyCell: {}
}
});

// eslint-disable-next-line max-lines-per-function
render() {
const { classes } = this.props;
const { filteredMessages } = this.state;
return (
<Fragment>
<MUIDataTable
data={filteredMessages}
columns={this.columns}
options={this.options}
/>
</Fragment>
);
}
}
MessageManager.propTypes = {
classes: PropTypes.object.isRequired
};

export default withStyles(styles)(MessageManager);
4 changes: 4 additions & 0 deletions examples/resizable-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ function Example(props) {
</FormControl>
<div style={{marginLeft: marginLeft + 'px'}}>
<MUIDataTable title={"ACME Employee list" + " [" + counter + "]"} data={data} columns={columns} options={options} />
<div>
<MUIDataTable title={"ACME Employee list"} data={data} columns={columns} options={options} />
</div>
<MUIDataTable title={"ACME Employee list"} data={data} columns={columns} options={options} />
</div>
</>
);
Expand Down
Loading

0 comments on commit 8fb338e

Please sign in to comment.