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: Column Group Filters #6151

Closed
AquariusAdamM opened this issue Jul 30, 2024 · 2 comments · Fixed by #6197
Closed

DataTable: Column Group Filters #6151

AquariusAdamM opened this issue Jul 30, 2024 · 2 comments · Fixed by #6197
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@AquariusAdamM
Copy link

Describe the bug

When using ColumnGroup and setting type header I get the multiple rows for the header of the table but the filters disappear and can't be added to the columns.

<script setup>
import DataTable from 'primevue/datatable'
import Column from 'primevue/column'
import ColumnGroup from 'primevue/columngroup'
import Row from 'primevue/row'
import { ref } from 'vue'

const filters = ref({
  title: ''
})
</script>
<template>
  <DataTable v-model:filters="filters" filterDisplay="row">
    <ColumnGroup type="header">
      <Row>
        <Column header="Something" :colspan="2" field="title" />
        <Column header="Important" :colspan="1" field="due_date" />
      </Row>
      <Row>
        <Column header="Title" field="title" />
        <Column header="Due Date" field="due_date" />
        <Column header="Team" field="team" />
      </Row>
    </ColumnGroup>
    <Column header="Title" field="title" :show-filter-menu="false">
      <template #filter>
        <input v-model="filters.title" placeholder="Search by Title" />
      </template>
    </Column>
    <Column header="Due Date" field="due_date" />
    <Column header="Team" field="team" />
    <template #empty>No data</template>
  </DataTable>
</template>

image

If I remove the type from the ColumnGroup, I don't get the multiple headers on the table but I regain the ability to use filters on the data table.

<script setup>
import DataTable from 'primevue/datatable'
import Column from 'primevue/column'
import ColumnGroup from 'primevue/columngroup'
import Row from 'primevue/row'
import { ref } from 'vue'

const filters = ref({
  title: ''
})
</script>
<template>
  <DataTable v-model:filters="filters" filterDisplay="row">
    <ColumnGroup>
      <Row>
        <Column header="Something" :colspan="2" field="title" />
        <Column header="Important" :colspan="1" field="due_date" />
      </Row>
      <Row>
        <Column header="Title" field="title" />
        <Column header="Due Date" field="due_date" />
        <Column header="Team" field="team" />
      </Row>
    </ColumnGroup>
    <Column header="Title" field="title" :show-filter-menu="false">
      <template #filter>
        <input v-model="filters.title" placeholder="Search by Title" />
      </template>
    </Column>
    <Column header="Due Date" field="due_date" />
    <Column header="Team" field="team" />
    <template #empty>No data</template>
  </DataTable>
</template>

image

Reproducer

https://stackblitz.com/edit/primevue-4-datatable-columngroup-filter?file=src%2FApp.vue

PrimeVue version

4.0.0

Vue version

4.x

Language

ES6

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

I would expect the filter to be showing when you add type="header" to a ColumnGroup.

@AquariusAdamM AquariusAdamM added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 30, 2024
@brandolin-infofactory
Copy link

+1
We have the same need

avramz added a commit to avramz/primevue that referenced this issue Aug 7, 2024
@tugcekucukoglu tugcekucukoglu added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 21, 2024
@tugcekucukoglu tugcekucukoglu added this to the 4.1.0 milestone Aug 21, 2024
tugcekucukoglu added a commit that referenced this issue Sep 24, 2024
#6151: refactor the TableHeader template so it renders filters when c…
@dmsmidt
Copy link

dmsmidt commented Oct 12, 2024

Fine work supporting this combination. Note that this only fixes the issue for filterDisplay="row" not filterDisplay="menu". Would also be great to have.

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

Successfully merging a pull request may close this issue.

4 participants