Skip to content

How can I export the table with the selected rows #567

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

Closed
kyuch4n opened this issue Jul 18, 2016 · 4 comments
Closed

How can I export the table with the selected rows #567

kyuch4n opened this issue Jul 18, 2016 · 4 comments
Labels

Comments

@kyuch4n
Copy link

kyuch4n commented Jul 18, 2016

image

  1. The return value of the function which is "onExportToCSV" must "the rows which need to be exported",
    but what is the struct of the return value?
  2. Is my usage Effective? or what is the correct usage
    Thank u
@kyuch4n
Copy link
Author

kyuch4n commented Jul 18, 2016

The attributes REMOTE must be true, then the table can be exported with the selected rows...means you must handle the data filtering, sorting, adding or removing etc on your own.

@AllenFang
Copy link
Owner

AllenFang commented Jul 19, 2016

You need to return the rows inonExportToCSV, which the structure is same as the value of data props on <BootstrapTable>.

I write a example without testing, maybe you can try it

class ExportCSVTable extends React.Component {

  onExportToCSV = () => {
    const selectedRows = this.refs.table.state.selectedRowKeys;
    return products.filter(prod => {
      if (selectedRows.indexOf(prod.id) > -1) {
        return prod;
      }
    });
  }

  render() {
    const selectRow = {
      mode: 'checkbox'
    };

    const options = {
      onExportToCSV: this.onExportToCSV
    };

    return (
      <BootstrapTable ref='table' data={ products } exportCSV={ true } options={ options } selectRow={ selectRow }>
          <TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
          <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
          <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
      </BootstrapTable>
    );
  }
}

@AllenFang AllenFang reopened this Jul 19, 2016
@AllenFang
Copy link
Owner

Sorry, I thinks the snippet is not work. BTW, you are right, I need to do some fixing for avoid onExportToCSV is only work on REMOTE condition.

@AllenFang AllenFang added the bug label Jul 19, 2016
AllenFang added a commit that referenced this issue Jul 25, 2016
@AllenFang
Copy link
Owner

@Basketballislife, this issue fixed on v2.3.9. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants