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

Column Filter: Expose 'applyFilter' method #3519

Closed
BenjaminMINK opened this issue Jan 11, 2023 · 5 comments
Closed

Column Filter: Expose 'applyFilter' method #3519

BenjaminMINK opened this issue Jan 11, 2023 · 5 comments
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@BenjaminMINK
Copy link
Contributor

Describe the feature you would like to see added

Expose the applyFilter method to custom filter template can be handful in order to close the overlay on keydown event for example

Is your feature request related to a problem?

No response

Describe the solution you'd like

No response

Describe alternatives you have considered

No response

Additional context

No response

@BenjaminMINK BenjaminMINK added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Jan 11, 2023
@tugcekucukoglu
Copy link
Member

Thanks for the PR. I looked into it but calling the applyFilter method still closes the overlay panel. Am I missing something?

@BenjaminMINK
Copy link
Contributor Author

Yes, that's exactly the purpose of the PR, here is a code sample to better understand the request:

With only filterCallback apply the filter and the overlay stays open:

<Column field="name" header="Name" style="min-width:12rem">
                    <template #body="{data}">
                        {{data.name}}
                    </template>
                    <template #filter="{filterModel,filterCallback}">
                        <InputText type="text" v-model="filterModel.value" @keydown.enter="filterCallback()" class="p-column-filter" :placeholder="`Search by name - `" v-tooltip.top.focus="'Hit enter key to filter'"/>
                    </template>
                </Column>

With applyFilter it will apply the filter and close the overlay:

<Column field="name" header="Name" style="min-width:12rem">
                    <template #body="{data}">
                        {{data.name}}
                    </template>
                    <template #filter="{filterModel,applyFilter}">
                        <InputText type="text" v-model="filterModel.value" @keydown.enter="applyFilter()" class="p-column-filter" :placeholder="`Search by name - `" v-tooltip.top.focus="'Hit enter key to filter'"/>
                    </template>
                </Column>

@tugcekucukoglu tugcekucukoglu added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Sep 6, 2023
@tugcekucukoglu tugcekucukoglu added this to the 3.34.1 milestone Sep 6, 2023
@eness
Copy link

eness commented Jan 4, 2024

this feature does not work as mentioned, in the latest version.

Try it on this official filter features demo : https://stackblitz.com/run?file=src%2FApp.vue

Replace Name column's filter as below and try to search something by pressing Enter key.

<template #filter="{ filterModel, applyFilter }">
       <InputText v-model="filterModel.value" @keydown.enter="applyFilter()" type="text" class="p-column-filter" placeholder="Search by name" />
</template>

@BenjaminMINK
Copy link
Contributor Author

this feature does not work as mentioned, in the latest version.

what does not work? what are you expecting?

Try it on this official filter features demo : https://stackblitz.com/run?file=src%2FApp.vue

This link won't work directly

Replace Name column's filter as below and try to search something by pressing Enter key.

<template #filter="{ filterModel, applyFilter }">
       <InputText v-model="filterModel.value" @keydown.enter="applyFilter()" type="text" class="p-column-filter" placeholder="Search by name" />
</template>

You may need to use keydown.enter.prevent instead

@eness
Copy link

eness commented Jan 11, 2024

Thank you @BenjaminMINK keydown.enter.prevent solved the issue. Official examples do not mention this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

3 participants