diff --git a/src/components/TableToolbar.js b/src/components/TableToolbar.js index 1f264de27..d81b9185a 100644 --- a/src/components/TableToolbar.js +++ b/src/components/TableToolbar.js @@ -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; }), }; });