Skip to content
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

[Table] Multiple Tables In Same Component #1084

Closed
valinol opened this issue Jul 9, 2015 · 3 comments
Closed

[Table] Multiple Tables In Same Component #1084

valinol opened this issue Jul 9, 2015 · 3 comments
Labels
component: table This is the name of the generic UI component, not the React module!

Comments

@valinol
Copy link

valinol commented Jul 9, 2015

Im testing the table and i have a few question:

1.- Can i use 2 tables in the same render? i want to select one element from the first table and another from the second table, but when i select from the second change the selected element from the first table and disappeared.

2.- I add the onRowSelection with a console.log, but this print the selected row four to five times.
capturatabla

This is part of the code
let Main = React.createClass({

childContextTypes: {
muiTheme: React.PropTypes.object
},

getChildContext() {
return {
muiTheme: ThemeManager.getCurrentTheme()
};
},

componentWillMount() {
ThemeManager.setPalette({
accent1Color: Colors.deepOrange500
});
},
_selecttablauno: function(e) {
console.log(e);
},
_selecttablados: function(e) {
console.log(e);
},

render() {

let containerStyle = {
  paddingTop: '0px'
};

let tableStyle = {
  width: '100%',
  overflow: 'auto'
};

let standardActions = [
  { text: 'Okay' }
];

// Row data
let rowData = [
{id: {content: '1'}, name: {content: 'John Smith but larger'}, status: {content: 'Employed'}, mas: {content: 'what if i use a long long long long'}},
{id: {content: '2'}, name: {content: 'Randal White'}, status: {content: 'Unemployed'}},
{id: {content: '3'}, name: {content: 'Stephanie Sanders'}, status: {content: 'Employed'}},
{id: {content: '4'}, name: {content: 'Steve Brown'}, status: {content: 'Employed'}},
{id: {content: '5'}, name: {content: 'Joyce Whitten'}, status: {content: 'Employed'}},
{id: {content: '6'}, name: {content: 'Samuel Roberts'}, status: {content: 'Unemployed'}},
{id: {content: '7'}, name: {content: 'Adam Moore'}, status: {content: 'Employed'}},
{id: {content: '8'}, name: {content: 'Robert Brown'}, status: {content: 'Employed'}},
{id: {content: '9'}, name: {content: 'Elizabeth Stevenson'}, status: {content: 'Employed'}},
{id: {content: '10'}, name: {content: 'Zachary Dobb'}, status: {content: 'Employed'}},
{id: {content: '11'}, name: {content: 'Zachary Dobb'}, status: {content: 'Employed'}}
];

// Row data
let rowData2 = [
{id: {content: '1'}, name: {content: 'John Smith but larger'}, status: {content: 'Employed'}, mas: {content: 'what if i use a long long long long'}},
{id: {content: '2'}, name: {content: 'Randal White'}, status: {content: 'Unemployed'}},
{id: {content: '3'}, name: {content: 'Stephanie Sanders'}, status: {content: 'Employed'}},
{id: {content: '4'}, name: {content: 'Steve Brown'}, status: {content: 'Employed'}},
{id: {content: '5'}, name: {content: 'Joyce Whitten'}, status: {content: 'Employed'}},
{id: {content: '6'}, name: {content: 'Samuel Roberts'}, status: {content: 'Unemployed'}},
{id: {content: '7'}, name: {content: 'Adam Moore'}, status: {content: 'Employed'}},
{id: {content: '8'}, name: {content: 'Robert Brown'}, status: {content: 'Employed'}},
{id: {content: '9'}, name: {content: 'Elizabeth Stevenson'}, status: {content: 'Employed'}},
{id: {content: '10'}, name: {content: 'Zachary Dobb'}, status: {content: 'Employed'}},
{id: {content: '11'}, name: {content: 'Zachary Dobb'}, status: {content: 'Employed'}}
];

// State
this.state = {
selectedItem:1,
fixedHeader: true,
fixedFooter: false,
stripedRows: false,
showRowHover: false,
selectable: true,
multiSelectable: false,
canSelectAll: false,
height: '300px',
rowData: rowData,
rowData2: rowData2
};

// Column configuration
let headerCols = {
id: {
content: 'ID',
tooltip: 'The ID'
},
name: {
content: 'Name',
tooltip: 'The name'
},
status: {
content: 'Status',
tooltip: 'The status'
},
otro: {
content: 'Two',
tooltip: 'The other'
},
mas: {
content: 'newa',
tooltip: 'The newa'
},
tres: {
content: 'four',
tooltip: 'The fourth'
}
};
let colOrder = ['id', 'name', 'status','otro','mas','tres'];
// Footer column content can also be specified as [ 'ID', 'Name', 'Status'].
let footerCols = {};

return (

  <div style={containerStyle}>
    <h2>example project</h2>

    <div style={tableStyle}>
      <Table 
        onRowSelection={this._selecttablauno}
        headerColumns={headerCols}
        footerColumns={footerCols}
        columnOrder={colOrder}
        rowData={this.state.rowData}
        height={this.state.height}
        fixedHeader={this.state.fixedHeader}
        fixedFooter={this.state.fixedFooter}
        stripedRows={this.state.stripedRows}
        showRowHover={this.state.showRowHover}
        selectable={this.state.selectable}
        multiSelectable={this.state.multiSelectable}
        canSelectAll={this.state.canSelectAll} />
      </div>
              <div style={tableStyle}>
      <Table 
        onRowSelection={this._selecttablauno}
        headerColumns={headerCols}
        footerColumns={footerCols}
        columnOrder={colOrder}
        rowData={this.state.rowData2}
        height={this.state.height}
        fixedHeader={this.state.fixedHeader}
        fixedFooter={this.state.fixedFooter}
        stripedRows={this.state.stripedRows}
        showRowHover={this.state.showRowHover}
        selectable={this.state.selectable}
        multiSelectable={this.state.multiSelectable}
        canSelectAll={this.state.canSelectAll} />
      </div>

  </div>
);

},

});

@jkruder
Copy link
Contributor

jkruder commented Jul 9, 2015

@valinol You should be able to use two tables at the same time. I can't say for certain though -- not something I explicitly tested. I'll test that out and see if I can recreate what you're seeing.

In regards to multiple calls, we have a PR for that that needs some updating. See #954. If we don't get a response from @mkucharz in the next day or so I'll wrap up what he started.

@jkruder jkruder changed the title Problem with table [Table] Problem with table Jul 9, 2015
@jkruder jkruder changed the title [Table] Problem with table [Table] Multiple Tables In Same Component Jul 9, 2015
@jkruder jkruder self-assigned this Jul 9, 2015
@jkruder
Copy link
Contributor

jkruder commented Jul 9, 2015

@valinol The issue with multiple tables has been resolved. You just need to set the deselectOnClickaway property to false.

@valinol
Copy link
Author

valinol commented Jul 10, 2015

thanks

@valinol valinol closed this as completed Jul 10, 2015
mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
* Support keyboardIcon for v3. closes mui#1084

* Add new prop to the docs
@zannager zannager added the component: table This is the name of the generic UI component, not the React module! label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants