Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeTable: Unable to custom columns' filter #5382

Closed
BAISTM opened this issue Nov 23, 2023 · 14 comments · Fixed by #7366
Closed

TreeTable: Unable to custom columns' filter #5382

BAISTM opened this issue Nov 23, 2023 · 14 comments · Fixed by #7366
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@BAISTM
Copy link

BAISTM commented Nov 23, 2023

Describe the bug

Using the columns' filterElement prop is not working. The passed function is not called.

Reproducer

https://codesandbox.io/p/sandbox/primereact-demo-forked-7j2jpq?file=%2Fsrc%2FApp.js%3A40%2C68-40%2C81

PrimeReact version

10.0.9

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@BAISTM BAISTM added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 23, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 23, 2023
@BAISTM
Copy link
Author

BAISTM commented Nov 23, 2023

@melloware There is any work-around that will make us customize TreeTable filters and calls primereact filters function?

Thank you for your response!

@melloware
Copy link
Member

I will take a look.

@toddsmith-adsk
Copy link

toddsmith-adsk commented Dec 5, 2023

https://codesandbox.io/p/sandbox/primereact-demo-forked-dc785t?file=%2Fsrc%2FApp.js%3A137%2C24

Works for DataTable but not TreeTable.

DataTable uses ObjectUtils.getJSXElement() and TreeTable does not.

const createFilterElement = (model, index) => {
        const value = model ? model.value : null;

        return getColumnProp('filterElement') ? (
            ObjectUtils.getJSXElement(getColumnProp('filterElement'), { field, index, filterModel: model, value, filterApplyCallback, filterCallback })
        ) : (
            <InputText
                type={getColumnProp('filterType')}
                value={value || ''}
                onChange={(e) => onInputChange(e, index)}
                onKeyDown={(e) => onInputKeydown(e, index)}
                className="p-column-filter"
                placeholder={getColumnProp('filterPlaceholder')}
                maxLength={getColumnProp('filterMaxLength')}
                aria-label={getColumnProp('filterPlaceholder')}
                unstyled={props.unstyled}
                __parentMetadata={{ parent: props.metaData }}
            />
        );
    };
      if (getColumnProp(column, 'filter') && options.renderFilter) {
            filterElement = getColumnProp(column, 'filterElement') || (
                <InputText
                    onInput={(e) => onFilterInput(e, column)}
                    type={props.filterType}
                    defaultValue={props.filters && props.filters[getColumnProp(column, 'field')] ? props.filters[getColumnProp(column, 'field')].value : null}
                    className="p-column-filter"
                    placeholder={getColumnProp(column, 'filterPlaceholder')}
                    maxLength={getColumnProp(column, 'filterMaxLength')}
                    pt={getColumnPTOptions(column, 'filterInput')}
                    unstyled={props.unstyled}
                    __parentMetadata={{ parent: props.metaData }}
                />
            );
        }

@melloware
Copy link
Member

I looked and TreeTable is definitely missing a lot compared to Datatable as far as custom filtering goes

@toddsmith-adsk
Copy link

BTW this code looks odd in TreeTable.js

if (
  (isStrictMode && !(findFilteredNodes(copyNode, paramsWithoutNode) || isFilterMatched(copyNode, paramsWithoutNode))) ||
  (!isStrictMode && !(isFilterMatched(copyNode, paramsWithoutNode) || findFilteredNodes(copyNode, paramsWithoutNode)))
) {
  localMatch = false;
}

@Zbatux
Copy link

Zbatux commented Dec 15, 2023

Did anyone manage to find a workaround for this bug ? (Beside filtering the data itself before giving it to TreeTable Component)

@prabhat0192
Copy link

is there any work around available as i am also facing this issue.

@mtsmith
Copy link

mtsmith commented Mar 1, 2024

I ended up forking the code and making my own custom build.

@melloware
Copy link
Member

@mtsmith why not submit a PR? Wouldn't that be easier than maintaining your own custom build?

@toddsmith-adsk
Copy link

@mtsmith why not submit a PR? Wouldn't that be easier than maintaining your own custom build?

I need the fix asap so I can get other features working.

@iemi111
Copy link

iemi111 commented Apr 17, 2024

Would any of the people with a solution be willing to create a PR?
If not what is happening with this issue? It's been 5 months since this was raised and it's a pretty significant feature.

@Mrudula-Nemani
Copy link

I am also facing the same issue. The method is not getting called.

@melloware
Copy link
Member

@iemi111 @Mrudula-Nemani if no open source community member has submitted a PR you would have to look to PrimeReact PRO support or financially sponsor the one time fix https://primereact.org/support/

@toddsmith-adsk
Copy link

Sorry I don't have time for a PR but here is the fix

image

mlyaho added a commit to mlyaho/primereact-i5382 that referenced this issue Oct 23, 2024
TreeTable: Unable to custom columns' filter primefaces#5382
mlyaho added a commit to mlyaho/primereact-i5382 that referenced this issue Oct 24, 2024
TreeTable: Unable to custom columns' filter primefaces#5382
@melloware melloware added this to the 10.8.5 milestone Oct 24, 2024
melloware pushed a commit that referenced this issue Oct 24, 2024
TreeTable: Unable to custom columns' filter #5382
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants