Skip to content

Commit

Permalink
Fix primefaces#1450: Datatable/Treetable add globalFilterMatchMode
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 1, 2022
1 parent 9ad20e3 commit de87140
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 245 deletions.
6 changes: 6 additions & 0 deletions api-generator/components/datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ const DataTableProps = [
default: 'null',
description: 'Value of the global filter to use in filtering.'
},
{
name: 'globalFilterMatchMode',
type: 'string',
default: 'contains',
description: 'Defines filterMatchMode; "startsWith", "contains", "endsWith", "equals", "notEquals", "in", "lt", "lte", "gt", "gte" and "custom".'
},
{
name: 'filterDelay',
type: 'number',
Expand Down
6 changes: 6 additions & 0 deletions api-generator/components/treetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ const TreeTableProps = [
default: 'null',
description: 'Value of the global filter to use in filtering.'
},
{
name: 'globalFilterMatchMode',
type: 'string',
default: 'contains',
description: 'Defines filterMatchMode; "startsWith", "contains", "endsWith", "equals", "notEquals", "in", "lt", "lte", "gt", "gte" and "custom".'
},
{
name: 'filterMode',
type: 'string',
Expand Down
18 changes: 12 additions & 6 deletions components/doc/datatable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3353,12 +3353,6 @@ export const DataTableStateDemo = () => {
<td>null</td>
<td>An array of FilterMetadata objects to provide external filters.</td>
</tr>
<tr>
<td>globalFilter</td>
<td>any</td>
<td>null</td>
<td>Value of the global filter to use in filtering.</td>
</tr>
<tr>
<td>filterDelay</td>
<td>number</td>
Expand Down Expand Up @@ -3577,12 +3571,24 @@ export const DataTableStateDemo = () => {
<td>pi pi-chevron-up</td>
<td>Icon of the row toggler to display the row as collapsed.</td>
</tr>
<tr>
<td>globalFilter</td>
<td>any</td>
<td>null</td>
<td>Value of the global filter to use in filtering.</td>
</tr>
<tr>
<td>globalFilterFields</td>
<td>string[]</td>
<td>null</td>
<td>Define fields to be filtered globally.</td>
</tr>
<tr>
<td>globalFilterMatchMode</td>
<td>string</td>
<td>contains</td>
<td>Defines filterMatchMode; "startsWith", "contains", "endsWith", "equals", "notEquals", "in", "lt", "lte", "gt", "gte" and "custom".</td>
</tr>
<tr>
<td>showSelectionElement</td>
<td>function</td>
Expand Down
12 changes: 9 additions & 3 deletions components/doc/treetable/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { memo } from 'react';
import Link from 'next/link';
import { TabView, TabPanel } from '../../lib/tabview/TabView';
import { useLiveEditorTabs } from '../common/liveeditor';
import React, { memo } from 'react';
import { TabPanel, TabView } from '../../lib/tabview/TabView';
import { CodeHighlight } from '../common/codehighlight';
import { DevelopmentSection } from '../common/developmentsection';
import { useLiveEditorTabs } from '../common/liveeditor';

const TreeTableDoc = memo(() => {
const sources = {
Expand Down Expand Up @@ -2430,6 +2430,12 @@ export const TreeTableResponsiveDemo = () => {
<td>null</td>
<td>Value of the global filter to use in filtering.</td>
</tr>
<tr>
<td>globalFilterMatchMode</td>
<td>string</td>
<td>contains</td>
<td>Defines filterMatchMode; "startsWith", "contains", "endsWith", "equals", "notEquals", "in", "lt", "lte", "gt", "gte" and "custom".</td>
</tr>
<tr>
<td>filterMode</td>
<td>string</td>
Expand Down
219 changes: 110 additions & 109 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ export const DataTable = React.forwardRef((props, ref) => {
if (isGlobalFilter && !globalMatch && globalFilterFieldsArray) {
for (let j = 0; j < globalFilterFieldsArray.length; j++) {
let globalFilterField = globalFilterFieldsArray[j];
let matchMode = filters['global'] ? filters['global'].matchMode : FilterMatchMode.CONTAINS;
let matchMode = filters['global'] ? filters['global'].matchMode : props.globalFilterMatchMode;
let value = filters['global'] ? filters['global'].value : props.globalFilter;

globalMatch = FilterService.filters[matchMode](ObjectUtils.resolveFieldData(data[i], globalFilterField), value, props.filterLocale);
Expand Down Expand Up @@ -1767,132 +1767,133 @@ export const DataTable = React.forwardRef((props, ref) => {
DataTable.displayName = 'DataTable';
DataTable.defaultProps = {
__TYPE: 'DataTable',
id: null,
value: null,
header: null,
footer: null,
style: null,
className: null,
tableStyle: null,
tableClassName: null,
paginator: false,
paginatorPosition: 'bottom',
alwaysShowPaginator: true,
paginatorClassName: null,
paginatorTemplate: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
paginatorLeft: null,
paginatorRight: null,
paginatorDropdownAppendTo: null,
pageLinkSize: 5,
rowsPerPageOptions: null,
currentPageReportTemplate: '({currentPage} of {totalPages})',
first: 0,
rows: null,
totalRecords: null,
lazy: false,
sortField: null,
sortOrder: null,
multiSortMeta: null,
sortMode: 'single',
defaultSortOrder: 1,
removableSort: false,
emptyMessage: null,
selectionMode: null,
dragSelection: false,
autoLayout: false,
breakpoint: '960px',
cellClassName: null,
cellSelection: false,
selection: null,
selectionAriaLabel: null,
onSelectionChange: null,
contextMenuSelection: null,
onContextMenuSelectionChange: null,
compareSelectionBy: 'deepEquals',
dataKey: null,
metaKeySelection: true,
selectOnEdit: true,
selectionPageOnly: false,
selectionAutoFocus: true,
showSelectAll: true,
selectAll: false,
onSelectAllChange: null,
headerColumnGroup: null,
footerColumnGroup: null,
rowExpansionTemplate: null,
expandedRows: null,
onRowToggle: null,
resizableColumns: false,
className: null,
collapsedRowIcon: 'pi pi-chevron-right',
columnResizeMode: 'fit',
reorderableColumns: false,
reorderableRows: false,
filters: null,
globalFilter: null,
filterDelay: 300,
filterLocale: undefined,
scrollable: false,
scrollHeight: null,
scrollDirection: 'vertical',
virtualScrollerOptions: null,
frozenWidth: null,
frozenValue: null,
compareSelectionBy: 'deepEquals',
contextMenuSelection: null,
csvSeparator: ',',
exportFilename: 'download',
rowGroupMode: null,
autoLayout: false,
rowClassName: null,
cellClassName: null,
rowGroupHeaderTemplate: null,
rowGroupFooterTemplate: null,
loading: false,
loadingIcon: 'pi pi-spinner',
tabIndex: 0,
stateKey: null,
stateStorage: 'session',
groupRowsBy: null,
currentPageReportTemplate: '({currentPage} of {totalPages})',
customRestoreState: null,
customSaveState: null,
dataKey: null,
defaultSortOrder: 1,
dragSelection: false,
editMode: 'cell',
editingRows: null,
emptyMessage: null,
expandableRowGroups: false,
rowHover: false,
showGridlines: false,
stripedRows: false,
size: 'normal',
responsiveLayout: 'stack',
breakpoint: '960px',
filterDisplay: 'menu',
expandedRowIcon: 'pi pi-chevron-down',
collapsedRowIcon: 'pi pi-chevron-right',
onRowEditComplete: null,
expandedRows: null,
exportFilename: 'download',
exportFunction: null,
filterDelay: 300,
filterDisplay: 'menu',
filterLocale: undefined,
filters: null,
first: 0,
footer: null,
footerColumnGroup: null,
frozenValue: null,
frozenWidth: null,
globalFilter: null,
globalFilterFields: null,
showSelectionElement: null,
showRowReorderElement: null,
globalFilterMatchMode: FilterMatchMode.CONTAINS,
groupRowsBy: null,
header: null,
headerColumnGroup: null,
id: null,
isDataSelectable: null,
lazy: false,
loading: false,
loadingIcon: 'pi pi-spinner',
metaKeySelection: true,
multiSortMeta: null,
onAllRowsSelect: null,
onAllRowsUnselect: null,
onCellClick: null,
onCellSelect: null,
onCellUnselect: null,
onColReorder: null,
onColumnResizeEnd: null,
onColumnResizerClick: null,
onColumnResizerDoubleClick: null,
onSort: null,
onPage: null,
onContextMenu: null,
onContextMenuSelectionChange: null,
onFilter: null,
onAllRowsSelect: null,
onAllRowsUnselect: null,
onPage: null,
onRowClick: null,
onRowCollapse: null,
onRowDoubleClick: null,
onRowSelect: null,
onRowUnselect: null,
onRowEditCancel: null,
onRowEditChange: null,
onRowEditComplete: null,
onRowEditInit: null,
onRowEditSave: null,
onRowExpand: null,
onRowCollapse: null,
onContextMenu: null,
onColReorder: null,
onCellClick: null,
onCellSelect: null,
onCellUnselect: null,
onRowReorder: null,
onRowSelect: null,
onRowToggle: null,
onRowUnselect: null,
onSelectAllChange: null,
onSelectionChange: null,
onSort: null,
onStateRestore: null,
onStateSave: null,
onValueChange: null,
pageLinkSize: 5,
paginator: false,
paginatorClassName: null,
paginatorDropdownAppendTo: null,
paginatorLeft: null,
paginatorPosition: 'bottom',
paginatorRight: null,
paginatorTemplate: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown',
removableSort: false,
reorderableColumns: false,
reorderableRows: false,
resizableColumns: false,
responsiveLayout: 'stack',
rowClassName: null,
rowEditValidator: null,
onRowEditInit: null,
onRowEditSave: null,
onRowEditCancel: null,
onRowEditChange: null,
exportFunction: null,
customSaveState: null,
customRestoreState: null,
onStateSave: null,
onStateRestore: null
rowExpansionTemplate: null,
rowGroupFooterTemplate: null,
rowGroupHeaderTemplate: null,
rowGroupMode: null,
rowHover: false,
rows: null,
rowsPerPageOptions: null,
scrollDirection: 'vertical',
scrollHeight: null,
scrollable: false,
selectAll: false,
selectOnEdit: true,
selection: null,
selectionAriaLabel: null,
selectionAutoFocus: true,
selectionMode: null,
selectionPageOnly: false,
showGridlines: false,
showRowReorderElement: null,
showSelectAll: true,
showSelectionElement: null,
size: 'normal',
sortField: null,
sortMode: 'single',
sortOrder: null,
stateKey: null,
stateStorage: 'session',
stripedRows: false,
style: null,
tabIndex: 0,
tableClassName: null,
tableStyle: null,
totalRecords: null,
value: null,
virtualScrollerOptions: null
};
3 changes: 2 additions & 1 deletion components/lib/datatable/datatable.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Column } from '../column';
import { Column, ColumnFilterMatchModeType } from '../column';
import { PaginatorTemplate } from '../paginator';
import { VirtualScroller, VirtualScrollerProps } from '../virtualscroller/virtualscroller';

Expand Down Expand Up @@ -268,6 +268,7 @@ export interface DataTableProps extends Omit<React.DetailedHTMLProps<React.Input
frozenWidth?: string;
globalFilter?: DataTableGlobalFilterType;
globalFilterFields?: string[];
globalFilterMatchMode?: ColumnFilterMatchModeType;
groupRowsBy?: string;
header?: DataTableHeaderTemplateType;
headerColumnGroup?: React.ReactNode;
Expand Down
Loading

0 comments on commit de87140

Please sign in to comment.