Skip to content

Commit

Permalink
Fix issue by properly checking for basic js objects and preserve disp…
Browse files Browse the repository at this point in the history
…layed index (gregnb#964)

* Fix issue by properly checking for basic js objects

* Use displayed index to help preserve sorting arrangement
  • Loading branch information
gabrielliwerant authored and waqasajaz committed Oct 31, 2019
1 parent d734767 commit 2e39d76
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 2e39d76

Please sign in to comment.