AllenFang / AllenFang/react-bootstrap-table

Export csv with selected rows in react-bootstrap-table

未關閉
#1,980 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
2.2k
分支
761
PR 合併指標
30 天內沒有已合併 PR

描述

How can i export selected rows as csv file in react-bootstrap-table ? i'm using ^4.0.1 version

this is my code snippet.

const selectedForms = [];

function onRowSelect(row, isSelected) {
if (isSelected) {
selectedForms.push(row.id);
} else {
selectedForms.splice((selectedForms.indexOf(row.id)), 1);
}
console.log(selectedForms.toString());
}

const selectRowProp = {
mode: 'checkbox',
onSelect: onRowSelect,
};

{
this.props.history.push(`/form/${row.id}`);
},
onExportToCSV: () => {
return this.props.forms.map(form => (selectedForms.indexOf(form.id) > -1));
},
}}
selectRow={selectRowProp}
>
Subscriber form ID
Column1
Column2
Column3
Column4

This is the erro message i'm getting :
Uncaught TypeError: Cannot read property 'length' of undefined
at o (csv_export_util.js:24)
at i (csv_export_util.js:80)
at t.value (BootstrapTable.js:1392)
at Object.n.handleExportCSV [as onExportCSV] (BootstrapTable.js:160)
at t.value (ToolBar.js:353)
at o.handleExportCSV (ToolBar.js:139)
at Object.h (react-dom.production.min.js:36)
at Object.invokeGuardedCallback (react-dom.production.min.js:35)
at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.production.min.js:35)
at b (react-dom.production.min.js:36)

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。