Skip to main content

API

The API is used to access VirtualTable methods and contents outside of it.

Example with exportData method

This code will create a button Export that export the VirtualTable content to the csv format.

const myRef = useRef();

function handleExport() {
myRef?.current?.exportData('csv');
}

return (
<div>
<button onClick={handleExport}>Export</button>
<VirtualTable ref={myRef} />
</div>
);

Available data and methods

NameTypeDescription
cancel() => voidSame action than clicking on the cancel button.
delete() => voidSame action than clicking on the delete button.
deleteNewRows() => voidRemove newly added rows.
edit() => voidSame action than clicking on the edit button.
exportData('csv' | 'xls' | 'pdf' | 'print' | 'output') => voidTrigger the export method. 'pdf' mode can hava params
getColumns() => object[]Returns the columns with the display property.
getData({ filtered: boolean }) => row[]Returns the table data. If filtered is true, it returns only the filtered result.
getFilters() => { filters: Map, q: string }Returns the filters state.
getSelectedRows() => number[]Returns the selection state.
save() => voidSame action than clicking on the save button.
selectRows(ids: number[]) => voidChange the selection state.
setCellValue({ key: string, keyId: number | string, value: any }) => void
setRowValue({ keyId: number | string, value: object }) => void
setCurrentCell(rowIndex: number, columnIndex: number) => voidChange the focused cell.

exportData pdf

const myRef = useRef();
const exportParams = {
title: {
line1: 'title',
line2: 'line2',
line3: 'line3',
logo: '',
logoFormat: 'png'
},
orientation: 'l',
fontSize: 8,
watermak: 'WATERMARK'
};

function handleExport() {
myRef?.current?.exportData('pdf', exportParams);
}

return (
<div>
<button onClick={handleExport}>Export</button>
<VirtualTable ref={myRef} />
</div>
);

Available data and methods

NameTypeDescription
title.line1stringFirst line of title, in the frame title
title.line2stringSub title of title, in the frame title
title.line3stringSub title of title, out of frame title
title.logostringTop right logo
title.logoFormatstringFormat of logo
orientationstring'p' default (portrait), 'l' large
fontSize: 8string'8' default, fontSize ref for the export
watermark: ''stringWatermark