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
Name | Type | Description |
---|---|---|
cancel | () => void | Same action than clicking on the cancel button. |
delete | () => void | Same action than clicking on the delete button. |
deleteNewRows | () => void | Remove newly added rows. |
edit | () => void | Same action than clicking on the edit button. |
exportData | ('csv' | 'xls' | 'pdf' | 'print' | 'output') => void | Trigger 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 | () => void | Same action than clicking on the save button. |
selectRows | (ids: number[]) => void | Change the selection state. |
setCellValue | ({ key: string, keyId: number | string, value: any }) => void | |
setRowValue | ({ keyId: number | string, value: object }) => void | |
setCurrentCell | (rowIndex: number, columnIndex: number) => void | Change 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
Name | Type | Description |
---|---|---|
title.line1 | string | First line of title, in the frame title |
title.line2 | string | Sub title of title, in the frame title |
title.line3 | string | Sub title of title, out of frame title |
title.logo | string | Top right logo |
title.logoFormat | string | Format of logo |
orientation | string | 'p' default (portrait), 'l' large |
fontSize: 8 | string | '8' default, fontSize ref for the export |
watermark: '' | string | Watermark |