Skip to content

Commit

Permalink
Fixed #1333 - Add filterLocale property to DataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 17, 2020
1 parent 35cefeb commit dbe7322
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ interface DataTableProps {
reorderableColumns?: boolean;
filters?: object;
globalFilter?: any;
filterLocale?: string;
scrollable?: boolean;
scrollHeight?: string;
virtualScroll?: boolean;
Expand Down
6 changes: 4 additions & 2 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class DataTable extends Component {
reorderableColumns: false,
filters: null,
globalFilter: null,
filterLocale: undefined,
scrollable: false,
scrollHeight: null,
virtualScroll: false,
Expand Down Expand Up @@ -157,6 +158,7 @@ export class DataTable extends Component {
reorderableColumns: PropTypes.bool,
filters: PropTypes.object,
globalFilter: PropTypes.any,
filterLocale: PropTypes.string,
scrollable: PropTypes.bool,
scrollHeight: PropTypes.string,
virtualScroll: PropTypes.bool,
Expand Down Expand Up @@ -1142,7 +1144,7 @@ export class DataTable extends Component {
let filterMatchMode = filterMeta.matchMode||col.props.filterMatchMode;
let filterConstraint = filterMatchMode === 'custom' ? col.props.filterFunction : FilterUtils[filterMatchMode];

if(!filterConstraint(dataFieldValue, filterValue)) {
if(!filterConstraint(dataFieldValue, filterValue, this.props.filterLocale)) {
localMatch = false;
}

Expand All @@ -1152,7 +1154,7 @@ export class DataTable extends Component {
}

if (!col.props.excludeGlobalFilter && this.props.globalFilter && !globalMatch) {
globalMatch = FilterUtils['contains'](ObjectUtils.resolveFieldData(value[i], columnField), this.props.globalFilter);
globalMatch = FilterUtils['contains'](ObjectUtils.resolveFieldData(value[i], columnField), this.props.globalFilter, this.props.filterLocale);
}
}

Expand Down

0 comments on commit dbe7322

Please sign in to comment.