Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 6f0cdff

Browse files
committed
Fix width radio select row
1 parent 889486b commit 6f0cdff

File tree

5 files changed

+115
-19
lines changed

5 files changed

+115
-19
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import MUIDataTable from '../../src/';
4+
5+
class Example extends React.Component {
6+
render() {
7+
const columns = ['Name', 'Teste', 'Title', 'Location', 'Age', { name: 'Salary', options: { hint: 'USD / year' } }];
8+
9+
const data = [
10+
['Gabby George', '', 'Business Analyst', 'Minneapolis', 30, 100000],
11+
['Aiden Lloyd', '', 'Business Consultant', 'Dallas', 55, 200000],
12+
['Jaden Collins', '', 'Attorney', 'Santa Ana', 27, 500000],
13+
['Franky Rees', '', 'Business Analyst', 'St. Petersburg', 22, 50000],
14+
['Aaren Rose', '', 'Business Consultant', 'Toledo', 28, 75000],
15+
['Blake Duncan', '', 'Business Management Analyst', 'San Diego', 65, 94000],
16+
['Frankie Parry', '', 'Agency Legal Counsel', 'Jacksonville', 71, 210000],
17+
['Lane Wilson', '', 'Commercial Specialist', 'Omaha', 19, 65000],
18+
['Robin Duncan', '', 'Business Analyst', 'Los Angeles', 20, 77000],
19+
['Mel Brooks', '', 'Business Consultant', 'Oklahoma City', 37, 135000],
20+
['Harper White', '', 'Attorney', 'Pittsburgh', 52, 420000],
21+
['Kris Humphrey', '', 'Agency Legal Counsel', 'Laredo', 30, 150000],
22+
['Frankie Long', '', 'Industrial Analyst', 'Austin', 31, 170000],
23+
['Brynn Robbins', '', 'Business Analyst', 'Norfolk', 22, 90000],
24+
['Justice Mann', '', 'Business Consultant', 'Chicago', 24, 133000],
25+
['Addison Navarro', '', 'Business Management Analyst', 'New York', 50, 295000],
26+
['Jesse Welch', '', 'Agency Legal Counsel', 'Seattle', 28, 200000],
27+
['Eli Mejia', '', 'Commercial Specialist', 'Long Beach', 65, 400000],
28+
['Gene Leblanc', '', 'Industrial Analyst', 'Hartford', 34, 110000],
29+
['Danny Leon', '', 'Computer Scientist', 'Newark', 60, 220000],
30+
['Lane Lee', '', 'Corporate Counselor', 'Cincinnati', 52, 180000],
31+
['Jesse Hall', '', 'Business Analyst', 'Baltimore', 44, 99000],
32+
['Danni Hudson', '', 'Agency Legal Counsel', 'Tampa', 37, 90000],
33+
['Terry Macdonald', '', 'Commercial Specialist', 'Miami', 39, 140000],
34+
['Justice Mccarthy', '', 'Attorney', 'Tucson', 26, 330000],
35+
['Silver Carey', '', 'Computer Scientist', 'Memphis', 47, 250000],
36+
['Franky Miles', '', 'Industrial Analyst', 'Buffalo', 49, 190000],
37+
['Glen Nixon', '', 'Corporate Counselor', 'Arlington', 44, 80000],
38+
['Gabby Strickland', '', 'Business Process Consultant', 'Scottsdale', 26, 45000],
39+
['Mason Ray', '', 'Computer Scientist', 'San Francisco', 39, 142000],
40+
];
41+
42+
const options = {
43+
filter: true,
44+
selectableRows: true,
45+
filterType: 'dropdown',
46+
responsive: 'stacked',
47+
rowsPerPage: 10,
48+
onRowsSelect: (rowsSelected, allRows) => {
49+
console.log(rowsSelected, allRows);
50+
},
51+
onRowsDelete: rowsDeleted => {
52+
console.log(rowsDeleted, 'were deleted!');
53+
},
54+
onChangePage: numberRows => {
55+
console.log(numberRows);
56+
},
57+
onSearchChange: searchText => {
58+
console.log(searchText);
59+
},
60+
onColumnSortChange: (column, direction) => {
61+
console.log(column, direction);
62+
},
63+
onColumnViewChange: (column, action) => {
64+
console.log(column, action);
65+
},
66+
onFilterChange: (column, filters) => {
67+
console.log(column, filters);
68+
},
69+
onCellClick: (cellIndex, rowIndex) => {
70+
console.log(cellIndex, rowIndex);
71+
},
72+
onRowClick: (rowData, rowState) => {
73+
console.log(rowData, rowState);
74+
},
75+
isRowSelectable: dataIndex => {
76+
//prevents selection of row with title "Attorney"
77+
return data[dataIndex][1] != 'Attorney';
78+
},
79+
};
80+
81+
return (
82+
<div>
83+
<MUIDataTable
84+
title={'ACME Employee list'}
85+
data={data}
86+
columns={columns}
87+
options={{ ...options, radio: true }}
88+
/>
89+
<br />
90+
<MUIDataTable title={'ACME Employee list'} data={data} columns={columns} options={options} />
91+
</div>
92+
);
93+
}
94+
}
95+
96+
ReactDOM.render(<Example />, document.getElementById('app-root'));

src/components/TableHead.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const defaultHeadStyles = theme => ({
1515
},
1616
width: '56px',
1717
maxWidth: '56px',
18-
backgroundColor: '#F4F7FA',
18+
padding: '0px',
1919
position: 'sticky',
2020
top: 0,
2121
zIndex: 3,

src/components/TableHeadCell.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ class TableHeadCell extends React.Component {
5858
sort: PropTypes.bool.isRequired,
5959
/** Hint tooltip text */
6060
hint: PropTypes.string,
61+
className: PropTypes.string,
6162
};
6263

6364
handleSortClick = () => {
6465
this.props.toggleSort(this.props.index);
6566
};
6667

6768
render() {
68-
const { children, classes, options, sortDirection, sort, hint, colSpan, rowSpan } = this.props;
69+
const { children, classes, options, sortDirection, sort, hint, colSpan, rowSpan, className } = this.props;
6970
const sortActive = sortDirection !== null && sortDirection !== undefined ? true : false;
7071

7172
const sortLabelProps = {
@@ -76,6 +77,7 @@ class TableHeadCell extends React.Component {
7677
const cellClass = classNames({
7778
[classes.root]: true,
7879
[classes.fixedHeader]: options.fixedHeader,
80+
[className]: true,
7981
});
8082

8183
return (

src/components/TableSelectCell.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const defaultSelectCellStyles = theme => ({
1414
},
1515
},
1616
sticky: {
17+
minWidth: '75px',
1718
width: '75px',
1819
maxWidth: '75px',
1920
top: 0,

webpack.config.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,40 @@ const webpack = require('webpack');
33

44
module.exports = {
55
entry: {
6-
app: "./examples/column-filters/index.js"
6+
app: './examples/selectable-rows-radio/index.js',
77
},
8-
stats: "verbose",
8+
stats: 'verbose',
99
context: __dirname,
10-
node : {
11-
fs: 'empty'
10+
node: {
11+
fs: 'empty',
1212
},
1313
output: {
14-
filename: 'bundle.js'
14+
filename: 'bundle.js',
1515
},
1616
devtool: 'source-map',
1717
devServer: {
1818
disableHostCheck: true,
1919
hot: true,
2020
inline: true,
21-
host: "0.0.0.0",
22-
port: 5050
21+
host: '0.0.0.0',
22+
port: 5050,
2323
},
2424
module: {
2525
rules: [
2626
{
2727
test: /\.jsx?$/,
2828
exclude: /(node_modules)/,
29-
use: [
30-
'babel-loader',
31-
'eslint-loader'
32-
]
33-
}
34-
]
29+
use: ['babel-loader', 'eslint-loader'],
30+
},
31+
],
3532
},
3633
plugins: [
3734
new webpack.HotModuleReplacementPlugin(),
3835
new webpack.NamedModulesPlugin(),
3936
new webpack.DefinePlugin({
4037
'process.env': {
41-
NODE_ENV: JSON.stringify("development"),
42-
}
43-
})
44-
]
38+
NODE_ENV: JSON.stringify('development'),
39+
},
40+
}),
41+
],
4542
};

0 commit comments

Comments
 (0)