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

useDisplayedRowsOnly caused the data index undefined #1815

Open
auntieyi opened this issue Nov 16, 2021 · 1 comment
Open

useDisplayedRowsOnly caused the data index undefined #1815

auntieyi opened this issue Nov 16, 2021 · 1 comment

Comments

@auntieyi
Copy link

Expected Behavior

            downloadOptions: {
                filterOptions: {
                    useDisplayedRowsOnly: true
                }
            },
            onDownload: (buildHead, buildBody, columns, data) => {
                console.log(data)
            },

Expected result like useDisplayedRowsOnly: false:
0: {index: 0, data: Array(16)}
1: {index: 1, data: Array(16)}

Current Behavior

undefined in index in current result:
0: {index: undefined, data: Array(16)}
1: {index: undefined, data: Array(16)}

Steps to Reproduce (for bugs)

  1. useDisplayedRowsOnly: true
  2. onDownload: (buildHead, buildBody, columns, data)
  3. console.log(data)

Your Environment

Tech Version
Material-UI ^5.0.6
MUI-datatables ^4.0.0
React ^16.14.0
browser Chrome
etc
@auntieyi
Copy link
Author

auntieyi commented Nov 16, 2021

I found there is a bug in src/components/TableToolbar.js, and here is the quick fix for me:

diff --git a/src/components/TableToolbar.js b/src/components/TableToolbar.js
index f1d3b8b..d5fe0ba 100644
--- a/src/components/TableToolbar.js
+++ b/src/components/TableToolbar.js
@@ -154,6 +154,7 @@ class TableToolbar extends React.Component {
           row.index = index;

           return {
+            index: row.dataIndex,
             data: row.data.map(column => {
               i += 1;

Hope can apply this fix in next release. Thanks.

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

No branches or pull requests

1 participant