Skip to content

Commit

Permalink
Fix primefaces#6501: Datatable expose sorts and filters in ref
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed May 1, 2024
1 parent e6d75fd commit 6059d57
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,10 @@ export const DataTable = React.forwardRef((inProps, ref) => {
restoreState,
restoreTableState,
saveState,
getFilters: () => filtersState,
setFilters: (filters) => setFiltersState(filters),
getSorts: () => multiSortMetaState,
setSorts: (sorts) => setMultiSortMetaState(sorts),
getElement: () => elementRef.current,
getTable: () => tableRef.current,
getVirtualScroller: () => virtualScrollerRef.current
Expand Down
22 changes: 22 additions & 0 deletions components/lib/datatable/datatable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,28 @@ export declare class DataTable<TValue extends DataTableValueArray> extends React
* Saves the state.
*/
public saveState(): void;
/**
* Retrieves the currently applied filters for the data table.
* @returns {DataTableFilterMeta | undefined} The currently applied filters, if any, or undefined if no filters are set.
*/
public getFilters(): DataTableFilterMeta | undefined;
/**
* Sets the filters for the data table.
* @param {DataTableFilterMeta} filters - The filters to be applied to the data table.
* @returns {void}
*/
public setFilters(filters: DataTableFilterMeta): void;
/**
* Retrieves the currently applied multiple sort metadata for the data table.
* @returns {DataTableSortMeta[] | undefined} The currently applied sorts, if any, or undefined if no sorts are set.
*/
public getSorts(): DataTableSortMeta[] | undefined;
/**
* Sets the multiple sort metadata for the data table.
* @param {DataTableSortMeta[]} sorts - The sorts to be applied to the data table.
* @returns {void}
*/
public setSorts(sorts: DataTableSortMeta[]): void;
/**
* Used to get container element.
* @return {HTMLDivElement} Container element
Expand Down

0 comments on commit 6059d57

Please sign in to comment.