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

DataTable/TreeTable: GlobalFilter not working with filterable="false" #7193

Closed
stefan-dan opened this issue Apr 2, 2021 · 10 comments · Fixed by #7428
Closed

DataTable/TreeTable: GlobalFilter not working with filterable="false" #7193

stefan-dan opened this issue Apr 2, 2021 · 10 comments · Fixed by #7428
Assignees
Labels
enhancement Additional functionality to current component workaround A workaround has been provided
Milestone

Comments

@stefan-dan
Copy link
Contributor

stefan-dan commented Apr 2, 2021

Describe the defect
Global filter works only on p:column that has atribute filtarable="true", but it should work on every column that has filterBy="" atribute.
I have a datatable where I need only the global filter, not the column filters. To disable column filter I use <p:column filterable="false"/>, but this breaks the GlobalFilter in PF10, in PF8 it works as expected.
I haven't tested yet, but this may affect treetable too.

Reproducer
Clone repository https://github.com/stefan-dan/primefaces-test

Environment:

  • PF Version: 10.0
  • JSF + version: Mojarra 2.2.8 and MyFaces 2.3.6
  • Affected browsers: ALL

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'http://localhost:8080/primefaces-test/'
  2. Click on 'Global filter Enter keyword'
  3. Write 'Stefan'
  4. Works as expected
  5. Write 'Moldova'
  6. See error

Expected behavior
Expected behaviour: Global filter should work on all p:columns that has atribute filterBy="", despite of filterable="" value.

Example XHTML

<p:dataTable var="customer" value="#{dtFilterView.customers1}" widgetVar="customersTable"
                             emptyMessage="No customers found with given criteria"
                             filteredValue="#{dtFilterView.filteredCustomers1}">

                    <f:facet name="header">
                        <div class="p-d-flex p-ai-center p-jc-between">
                            <span>List of Customers</span>
                            <p:inputText id="globalFilter" onkeyup="PF('customersTable').filter()" style="width:10rem" placeholder="Enter keyword" />
                        </div>
                    </f:facet>

                    <p:column headerText="Name" sortBy="#{customer.name}" filterBy="#{customer.name}" filterable="false">
                        <h:outputText value="#{customer.name}" />
                    </p:column>
</p:dataTable>
@stefan-dan stefan-dan added the 🐞 defect Bug...Something isn't working label Apr 2, 2021
@melloware
Copy link
Member

interesting. So if it is a global search you want it searching all columns but right now we filter only by active or filterable columns assuming you don't want the others checked.

@stefan-dan
Copy link
Contributor Author

@melloware yes, you can downgrade to PF 8 to see the behaviour I need. Or maybe there is a way to make the column filterable=true and to hide the input column filter?

@melloware
Copy link
Member

Yep you can hide the filters with this CSS.

body .ui-datatable .ui-column-customfilter,
body .ui-datatable .ui-column-filter {
   display: none;
}

@stefan-dan
Copy link
Contributor Author

stefan-dan commented Apr 2, 2021

Thank you, it is working. It's possible to know if it will be fixed, or should I apply this workaround?

@melloware
Copy link
Member

For now I would apply the workaround because I am not sure if the new behavior is actually the correct one. if I mark a column filterable="false" i would expect it to not be involved in filters. Becuase then how else will user exclude columns from the global filter? Marking as workaround and for discussion.

@melloware melloware added discussion Item needs to be discussed by core devs workaround A workaround has been provided and removed 🐞 defect Bug...Something isn't working labels Apr 2, 2021
@stefan-dan
Copy link
Contributor Author

User can exclude column from global and column filter by removing the filterBy attribute. I think that the attribute filterable duplicates the meaning of filterBy attribute, beacause why you will need to set filterBy for a column that you don't want to filter. We can replace filterable attribute with something like columnFilter or globalFilter. But this is only my opinion, thanks for fast reply.

@melloware
Copy link
Member

melloware commented Apr 2, 2021

because of this example: https://www.primefaces.org/showcase/ui/data/datatable/field.xhtml
Fields sets a whole bunch of defaults and you can turn things off with filterable="false" etc.

@asterisk360-admin
Copy link

asterisk360-admin commented Jun 4, 2021

The way in PF 10 adds more tags in all columns for implement the global filter.
Its lots of work hidding all the filters of columns with css.

I'm think add a parameter "hideFilter" in column will be helpfull.

@tandraschko tandraschko added this to the 11.0.0 milestone Jun 5, 2021
@tandraschko
Copy link
Member

yep, we need a param for that. maybe with name:

  1. hideFilter
  2. globalFilterOnly

Maybe others

@melloware
Copy link
Member

How about instead of hideFilter we use filterDisplayed with a default to true and you can hide it with filterDisplayed="false" that way it starts with the word "filter" so IDE's and our doc pages have it lined up with other filter props?

@melloware melloware self-assigned this Jun 15, 2021
@melloware melloware removed the discussion Item needs to be discussed by core devs label Jun 15, 2021
@melloware melloware linked a pull request Jun 15, 2021 that will close this issue
@melloware melloware added the enhancement Additional functionality to current component label Jun 15, 2021
melloware added a commit to melloware/primefaces that referenced this issue Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component workaround A workaround has been provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants