Skip to content

add support for disabling data table selection (checkbox/radio) #3126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

68 changes: 36 additions & 32 deletions components/data-table/__examples__/advanced-single-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,39 @@ const CustomDataTableCell = ({ children, ...props }) => (
);
CustomDataTableCell.displayName = DataTableCell.displayName;

const items = [
{
id: '8IKZHZZV80',
opportunityName: 'Acme - 1,200 Widgets',
accountName: 'Acme',
closeDate: '4/10/15',
stage: 'Value Proposition',
confidence: '70%',
amount: '$25,000,000',
contact: '[email protected]',
},
{
id: '5GJOOOPWU7',
opportunityName: 'Acme - 200 Widgets',
accountName: 'Acme',
closeDate: '1/31/15',
stage: 'Prospecting',
confidence: '30%',
amount: '$5,000,000',
contact: '[email protected]',
},
{
id: '8IKZHZZV81',
opportunityName: 'salesforce.com - 1,000 Widgets',
accountName: 'salesforce.com',
closeDate: '1/31/15 3:45PM',
stage: 'Id. Decision Makers',
confidence: '60%',
amount: '$25,000',
contact: '[email protected]',
},
];

class Example extends React.Component {
static displayName = 'DataTableExample';

Expand All @@ -23,39 +56,9 @@ class Example extends React.Component {
sortColumnDirection: {
opportunityName: 'asc',
},
items: [
{
id: '8IKZHZZV80',
opportunityName: 'Acme - 1,200 Widgets',
accountName: 'Acme',
closeDate: '4/10/15',
stage: 'Value Proposition',
confidence: '70%',
amount: '$25,000,000',
contact: '[email protected]',
},
{
id: '5GJOOOPWU7',
opportunityName: 'Acme - 200 Widgets',
accountName: 'Acme',
closeDate: '1/31/15',
stage: 'Prospecting',
confidence: '30%',
amount: '$5,000,000',
contact: '[email protected]',
},
{
id: '8IKZHZZV81',
opportunityName: 'salesforce.com - 1,000 Widgets',
accountName: 'salesforce.com',
closeDate: '1/31/15 3:45PM',
stage: 'Id. Decision Makers',
confidence: '60%',
amount: '$25,000',
contact: '[email protected]',
},
],
items,
selection: [],
disabledSelection: [items[0]],
};

handleChanged = (event, data) => {
Expand Down Expand Up @@ -123,6 +126,7 @@ class Example extends React.Component {
onRowChange={this.handleChanged}
onSort={this.handleSort}
selection={this.state.selection}
disabledSelection={this.state.disabledSelection}
selectRows="radio"
>
<DataTableColumn
Expand Down
248 changes: 126 additions & 122 deletions components/data-table/__examples__/fixed-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,129 @@ const CustomDataTableCell = ({ children, ...props }) => (
);
CustomDataTableCell.displayName = DataTableCell.displayName;

const items = [
{
id: '896a6a60',
opportunityName: 'Acme - 1,200 Widgets',
accountName: 'Acme',
closeDate: '4/10/15',
stage: 'Value Proposition',
confidence: '70%',
amount: '$25,000,000',
contact: '[email protected]',
},
{
id: '44da9dcd',
opportunityName: 'Acme - 200 Widgets',
accountName: 'Acme',
closeDate: '1/31/15',
stage: 'Prospecting',
confidence: '30%',
amount: '$5,000,000',
contact: '[email protected]',
},
{
id: 'f988a721',
opportunityName: 'salesforce.com - 1,000 Widgets',
accountName: 'salesforce.com',
closeDate: '1/31/15 3:45PM',
stage: 'Id. Decision Makers',
confidence: '60%',
amount: '$25,000',
contact: '[email protected]',
},
{
id: 'd7679cdd',
opportunityName: 'Acme - 800 Widgets',
accountName: 'Acme',
closeDate: '6/11/18',
stage: 'Value Proposition',
confidence: '85%',
amount: '$970,000',
contact: '[email protected]',
},
{
id: '0085f7a0',
opportunityName: 'Acme - 744 Widgets',
accountName: 'Acme',
closeDate: '4/15/17',
stage: 'Prospecting',
confidence: '56%',
amount: '$3,110,000',
contact: '[email protected]',
},
{
id: 'b7acc778',
opportunityName: 'salesforce.com - 847 Widgets',
accountName: 'salesforce.com',
closeDate: '5/23/18 1:02PM',
stage: 'Id. Decision Makers',
confidence: '62%',
amount: '$18,000',
contact: '[email protected]',
},
{
id: '17991de5',
opportunityName: 'Acme - 1,621 Widgets',
accountName: 'Acme',
closeDate: '5/16/17',
stage: 'Value Proposition',
confidence: '70%',
amount: '$23,600,000',
contact: '[email protected]',
},
{
id: '09b2cee9',
opportunityName: 'Acme - 430 Widgets',
accountName: 'Acme',
closeDate: '6/12/18',
stage: 'Prospecting',
confidence: '42%',
amount: '$4,222,222',
contact: '[email protected]',
},
{
id: 'd0035700',
opportunityName: 'salesforce.com - 677 Widgets',
accountName: 'salesforce.com',
closeDate: '7/21/17 10:11AM',
stage: 'Id. Decision Makers',
confidence: '42%',
amount: '$24,200',
contact: '[email protected]',
},
{
id: '4a526f0c',
opportunityName: 'Acme - 1,444 Widgets',
accountName: 'Acme',
closeDate: '3/18/18',
stage: 'Value Proposition',
confidence: '66%',
amount: '$22,000,000',
contact: '[email protected]',
},
{
id: '9a5dbdb2',
opportunityName: 'Acme - 320 Widgets',
accountName: 'Acme',
closeDate: '1/31/18',
stage: 'Prospecting',
confidence: '36%',
amount: '$4,322,000',
contact: '[email protected]',
},
{
id: '356dbb52',
opportunityName: 'salesforce.com - 4,000 Widgets',
accountName: 'salesforce.com',
closeDate: '2/21/17 8:33PM',
stage: 'Id. Decision Makers',
confidence: '72%',
amount: '$15,000',
contact: '[email protected]',
},
];

class Example extends React.Component {
static displayName = 'DataTableExample';

Expand All @@ -23,129 +146,9 @@ class Example extends React.Component {
sortColumnDirection: {
opportunityName: 'asc',
},
items: [
{
id: '896a6a60',
opportunityName: 'Acme - 1,200 Widgets',
accountName: 'Acme',
closeDate: '4/10/15',
stage: 'Value Proposition',
confidence: '70%',
amount: '$25,000,000',
contact: '[email protected]',
},
{
id: '44da9dcd',
opportunityName: 'Acme - 200 Widgets',
accountName: 'Acme',
closeDate: '1/31/15',
stage: 'Prospecting',
confidence: '30%',
amount: '$5,000,000',
contact: '[email protected]',
},
{
id: 'f988a721',
opportunityName: 'salesforce.com - 1,000 Widgets',
accountName: 'salesforce.com',
closeDate: '1/31/15 3:45PM',
stage: 'Id. Decision Makers',
confidence: '60%',
amount: '$25,000',
contact: '[email protected]',
},
{
id: 'd7679cdd',
opportunityName: 'Acme - 800 Widgets',
accountName: 'Acme',
closeDate: '6/11/18',
stage: 'Value Proposition',
confidence: '85%',
amount: '$970,000',
contact: '[email protected]',
},
{
id: '0085f7a0',
opportunityName: 'Acme - 744 Widgets',
accountName: 'Acme',
closeDate: '4/15/17',
stage: 'Prospecting',
confidence: '56%',
amount: '$3,110,000',
contact: '[email protected]',
},
{
id: 'b7acc778',
opportunityName: 'salesforce.com - 847 Widgets',
accountName: 'salesforce.com',
closeDate: '5/23/18 1:02PM',
stage: 'Id. Decision Makers',
confidence: '62%',
amount: '$18,000',
contact: '[email protected]',
},
{
id: '17991de5',
opportunityName: 'Acme - 1,621 Widgets',
accountName: 'Acme',
closeDate: '5/16/17',
stage: 'Value Proposition',
confidence: '70%',
amount: '$23,600,000',
contact: '[email protected]',
},
{
id: '09b2cee9',
opportunityName: 'Acme - 430 Widgets',
accountName: 'Acme',
closeDate: '6/12/18',
stage: 'Prospecting',
confidence: '42%',
amount: '$4,222,222',
contact: '[email protected]',
},
{
id: 'd0035700',
opportunityName: 'salesforce.com - 677 Widgets',
accountName: 'salesforce.com',
closeDate: '7/21/17 10:11AM',
stage: 'Id. Decision Makers',
confidence: '42%',
amount: '$24,200',
contact: '[email protected]',
},
{
id: '4a526f0c',
opportunityName: 'Acme - 1,444 Widgets',
accountName: 'Acme',
closeDate: '3/18/18',
stage: 'Value Proposition',
confidence: '66%',
amount: '$22,000,000',
contact: '[email protected]',
},
{
id: '9a5dbdb2',
opportunityName: 'Acme - 320 Widgets',
accountName: 'Acme',
closeDate: '1/31/18',
stage: 'Prospecting',
confidence: '36%',
amount: '$4,322,000',
contact: '[email protected]',
},
{
id: '356dbb52',
opportunityName: 'salesforce.com - 4,000 Widgets',
accountName: 'salesforce.com',
closeDate: '2/21/17 8:33PM',
stage: 'Id. Decision Makers',
confidence: '72%',
amount: '$15,000',
contact: '[email protected]',
},
],
items,
selection: [],
disabledSelection: [items[0]],
};

handleChanged = (event, data) => {
Expand Down Expand Up @@ -218,6 +221,7 @@ class Example extends React.Component {
onRowChange={this.handleChanged}
onSort={this.handleSort}
selection={this.state.selection}
disabledSelection={this.state.disabledSelection}
selectRows="checkbox"
>
<DataTableColumn
Expand Down
Loading