fix: Download button issue on server side pagination

This commit is contained in:
Kavin Venkatachalam 2025-04-04 13:35:34 +05:30
parent 5801817793
commit af1c9cb19d
2 changed files with 11 additions and 2 deletions

View file

@ -17,6 +17,7 @@ export const ControlButtons = memo(
shallow
);
const clientSidePagination = useTableStore((state) => state.getTableProperties(id)?.clientSidePagination, shallow);
const hasDownloadEvent = useTableStore((state) => state.getHasDownloadEvent(id), shallow);
const renderButton = (icon, onClick, tooltipId, tooltipContent) => {
return (
@ -142,7 +143,8 @@ export const ControlButtons = memo(
);
const renderDownloadButton = () => {
if (!clientSidePagination) {
// if server side pagination is enabled and download event is associated with the table, then directly fire download event without displaying popover
if (hasDownloadEvent && !clientSidePagination) {
const onClick = () => {
fireEvent('onTableDataDownload');
};
@ -173,7 +175,7 @@ export const ControlButtons = memo(
></ButtonSolid>
</>
)}
{renderDownloadButton()}
{showDownloadButton && renderDownloadButton()}
{!hideColumnSelectorButton &&
renderOverlay(id, 'eye1', hideColumnsPopover, 'tooltip-for-manage-columns', 'Manage columns')}
</div>

View file

@ -19,6 +19,7 @@ export const createInitSlice = (set, get) => ({
},
events: {
hasHoveredEvent: false,
hasDownloadEvent: false,
tableComponentEvents: [],
tableColumnEvents: [],
tableActionEvents: [],
@ -151,6 +152,9 @@ export const createInitSlice = (set, get) => ({
state.components[id].events.hasHoveredEvent = tableComponentEvents.some(
(event) => event.event.eventId === 'onRowHovered'
);
state.components[id].events.hasDownloadEvent = tableComponentEvents.some(
(event) => event.event.eventId === 'onTableDataDownload'
);
state.components[id].events.tableColumnEvents = tableEvents.filter((event) => event.target === 'table_column');
state.components[id].events.tableActionEvents = tableEvents.filter((event) => event.target === 'table_action');
},
@ -272,4 +276,7 @@ export const createInitSlice = (set, get) => ({
getHasHoveredEvent: (id) => {
return get().components[id]?.events?.hasHoveredEvent || false;
},
getHasDownloadEvent: (id) => {
return get().components[id]?.events?.hasDownloadEvent || false;
},
});