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

Fix issue by properly checking for basic js objects and preserve displayed index #964

Merged
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
10 changes: 7 additions & 3 deletions src/components/TableToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,19 @@ class TableToolbar extends React.Component {
if (options.downloadOptions && options.downloadOptions.filterOptions) {
// check rows first:
if (options.downloadOptions.filterOptions.useDisplayedRowsOnly) {
dataToDownload = displayData.map(row => {
dataToDownload = displayData.map((row, index) => {
let i = -1;

// Help to preserve sort order in custom render columns
row.index = index;

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

// if we have a custom render, we must grab the actual value from data
return typeof column === 'object' ? data[row.dataIndex].data[i] : column;
// if we have a custom render, which will appear as a react element, we must grab the actual value from data
// TODO: Create a utility function for checking whether or not something is a react object
return typeof column === 'object' && column !== null && !Array.isArray(column) ? data[row.index].data[i] : column;
}),
};
});
Expand Down