I am new to tabulator and react. I am trying to download only the selected rows which are checked in the tabulator table in the excel file. However I am not able to find any documentation on the same or any solution for the same.
I tried to implement this solution from Oli. However it is not working.
download only selected rows in Tabulator table?
Can anybody please help with a solution to this?
Here is my code:
the table formation:
const columnsSickWagon = [
{
formatter: "rowSelection",
titleFormatter: "rowSelection",
hozAlign: "center",
headerSort: false,
selectable:true,
**rowSelected:function(row){
row.update({selected:true});
},
rowDeselected:function(row){
row.update({selected:false});
},**
},
{
title: "Train No",
field: "trainNo",
align: "center",
headerFilter: "input",
headerFilterPlaceholder: "search...",
},
.....
I am using the bolded section as Oli mentioned in his solution
The download Function:
var sickWagonListmapref = null;
const downloadSickWagonData = async () => {
var table = sickWagonListmapref.table;
table.setFilter("selected", "=", true);
const date = new Date();
const fileName = "Sick Wagon Data" + date.toString() + ".xlsx";
table.download("xlsx", fileName, { sheetName: "Sheet1" });
};
React Render:
<ReactTabulator
ref={(ref) => {
sickWagonListmapref = ref;
}}
data={datasourceSickWagonData}
columns={columnsSickWagon}
options={{
layout: "fitDataFill",
height: 400,
// pagination: "local",
// paginationSize: 10,
downloadDataFormatter: (data) => data,
downloadReady: (fileContents, blob) => blob,
}}
/>
On trying to implement Olis solution what happens is the table goes blank and I get empty values in the excel.
Please help in this.