Skip to content

Commit

Permalink
Fix #6663: Show how to preserve filter object when mixing column and …
Browse files Browse the repository at this point in the history
…global filter (#6974)

Before the outerstate of DataTable was updated with the new global value and applied to column but local column state never bubbled to the outerstate and hence we loose information when global filter enter in action.
  • Loading branch information
Et7f3 authored Aug 2, 2024
1 parent f64fdb6 commit eef0068
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/doc/datatable/filter/advanceddoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function AdvancedFilterDoc(props) {
basic: `
<DataTable value={customers} paginator showGridlines rows={10} loading={loading} dataKey="id"
filters={filters} globalFilterFields={['name', 'country.name', 'representative.name', 'balance', 'status']} header={header}
emptyMessage="No customers found.">
emptyMessage="No customers found." onFilter={(e) => setFilters(e.filters)}>
<Column field="name" header="Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }} />
<Column header="Country" filterField="country.name" style={{ minWidth: '12rem' }} body={countryBodyTemplate}
filter filterPlaceholder="Search by country" filterClear={filterClearTemplate}
Expand Down Expand Up @@ -488,7 +488,7 @@ export default function AdvancedFilterDemo() {
<div className="card">
<DataTable value={customers} paginator showGridlines rows={10} loading={loading} dataKey="id"
filters={filters} globalFilterFields={['name', 'country.name', 'representative.name', 'balance', 'status']} header={header}
emptyMessage="No customers found.">
emptyMessage="No customers found." onFilter={(e) => setFilters(e.filters)}>
<Column field="name" header="Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }} />
<Column header="Country" filterField="country.name" style={{ minWidth: '12rem' }} body={countryBodyTemplate}
filter filterPlaceholder="Search by country" filterClear={filterClearTemplate}
Expand Down Expand Up @@ -784,7 +784,7 @@ export default function AdvancedFilterDemo() {
<div className="card">
<DataTable value={customers} paginator showGridlines rows={10} loading={loading} dataKey="id"
filters={filters} globalFilterFields={['name', 'country.name', 'representative.name', 'balance', 'status']} header={header}
emptyMessage="No customers found.">
emptyMessage="No customers found." onFilter={(e) => setFilters(e.filters)}>
<Column field="name" header="Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }} />
<Column header="Country" filterField="country.name" style={{ minWidth: '12rem' }} body={countryBodyTemplate}
filter filterPlaceholder="Search by country" filterClear={filterClearTemplate}
Expand Down Expand Up @@ -844,6 +844,7 @@ export default function AdvancedFilterDemo() {
globalFilterFields={['name', 'country.name', 'representative.name', 'balance', 'status']}
header={header}
emptyMessage="No customers found."
onFilter={(e) => setFilters(e.filters)}
>
<Column field="name" header="Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }} />
<Column
Expand Down

0 comments on commit eef0068

Please sign in to comment.