-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add custom wrapper support for helper components on DataTable and TreeTable #4646
Comments
@mertsincan, would this also work for DataTables with expandable rows? <template>
<CustomDataTable
v-model:expandedRows="expandedRows"
:value="products"
data-key="name"
>
<Column expander />
<CustomColumn field="price" header="Price" sortable>
<template #body="product">
{{ product.data.price }}
</template>
</CustomColumn >
<template #expansion="subrow">
<CustomDataTable :value="subrow.data.sub_rows" data-key="name">
<CustomColumn field="price" header="Price">
<template #body="subrow">
{{ subrow.data.price }}
</template>
</CustomColumn >
</CustomDataTable >
</template>
</CustomDataTable >
</template> |
Hi @moyoakala yes, you can use it. |
Why is this commit reverted may I ask? |
I only reverted my fixes for TabView and Accordion. Since they do not contain default slots, it was not technically possible to establish a structure like DataTable and TreeTable. We plan to make improvements to them in future versions. Currently, you can create custom wrapper components for DataTable and TreeTable. Best Regards, |
Cool. I was trying to create custom dynamic async tabpanel, which are loaded based on runtime conditions without v-if.Will the future improvement of tabview cover this? |
Do you know a way to create custom wrapper components for Accordion (including AccordionTab)? Was really looking forward to that. |
Unfortunately, there is no way for now :/ I plan to make improvements to them in future versions. |
I'm trying a similar approach to create a custom multiple selection column. But nothing is rendered TriStateSelectionColumn.vue <script lang="ts" setup>
const emits = defineEmits(['select'])
const selectionMode = ref(null)
</script>
<template>
<Column
:pt="{
headerCheckbox: {
class: 'hidden',
},
}"
header-style="width: 3rem"
selection-mode="multiple"
>
<template #header>
<TriStateCheckbox
v-model="selectionMode"
@update:model-value="emits('select', $event)"
>
<template #checkicon>
<Icon
color="white"
icon="minus"
/>
</template>
<template #uncheckicon>
<Icon
color="white"
icon="check"
/>
</template>
</TriStateCheckbox>
</template>
</Column>
</template> <DataTable
:selection="selectedValues"
:value="values"
>
<TriStateSelectionColumn
key="uid"
@select="onSelectChange"
/>
</Datatable> but nothing is rendered, Have you and idea ? |
@mertsincan Could you please provide example of working wrapper component for I have wrapped |
I'm having the same problem. My custom columns are not rendered in the DataTable component |
Same thing happen to me |
I did some tests here and I found a solution to temporarily resolve it. In my structure, I have a "DefaultTable" component and I just pass the columns to it, then my table columns are not inside the Datatable component. To make the custom columns rendered by the thrid component, I need to import them into my DefaultTable using the // DefaultTable.vue
<template>
<TableLoading v-if="tableData === null" />
<div
v-else
class="w-full overflow-y-auto"
>
<DataTable
ref="dt"
:value="tableData"
[...]
>
<template #header>[...]</template>
<StringColumn v-if="true" field="" header="" class="hidden" />
<ClassColumn v-if="true" field="" header="" class="hidden" />
<BooleanColumn v-if="true" field="" header="" class="hidden" />
[...]
<slot name="columns"></slot>
</DataTable>
</div>
</template>
<script lang="ts" setup>
import StringColumn from '@/components/tables/columns/default/StringColumn.vue'
import ClassColumn from '@/components/tables/columns/default/ClassColumn.vue'
import BooleanColumn from '@/components/tables/columns/default/BooleanColumn.vue'
[...]
</script> In the component where my table is built, i just pass the custom columns into the column slot reusing the //UsersPage.vue
<template>
<DefaultTable url="/users" [...]>
<template #columns>
<StringColumn
v-if="true"
field="idUser"
header="ID"
/>
<BooleanColumn
v-if="true"
field="online"
header="Connection Status"
true-text="Online"
false-text="Offline"
>
<template #body="{ data }">
<UserConnectionStatusChip :is-online="data.online" />
</template>
</BooleanColumn>
<ClassColumn
v-if="true"
field="companyBranch"
header="Company Branch"
:options="metadata.companyBranches"
/>
</template>
</DefaultTable>
</template>
<script lang="ts" setup>
import DefaultTable from '@/components/tables/DefaultTable.vue'
import StringColumn from '@/components/tables/columns/default/StringColumn.vue'
import BooleanColumn from '@/components/tables/columns/default/BooleanColumn.vue'
import ClassColumn from '@/components/tables/columns/default/ClassColumn.vue'
</script>
[...] |
Oh my god, thank you. That is a smart solution to overcome this issue. |
still got the issue on 4.0.0 |
So is |
Any working example of this? |
Well at least it works but it feels very unconventional DataTable.vue <DataTable>
<StatusColumn
v-if="true"
field="status"
header="status" />
</DataTable> StatusColumn.vue <template>
<Column
v-bind="props"
>
<template #body="{ data }">
{{data}}
</template>
</Column>
</template>
<script setup lang="ts">
import type { ColumnProps } from 'primevue/column';
import Column from 'primevue/column';
const props = defineProps<ColumnProps>();
</script> |
It works if column is a direct descendant of // SomethingList.vue
<List>
<LinkColumn v-if="true" field="title" header="Title />
</List> // List.vue
<DataTable>
<slot></slot>
</DataTable> |
This is still an issue in the latest version of Primevue (4.1.0). I cannot seem to wrap column with my own component. Anyone have a working sollution? |
anyone? |
same problem😿 |
Currently, primevue components such as DataTable need a helper component within themselves. These helper components must be directly child components. But sometimes users may need to wrap them with a custom wrapper instead of using them directly as children. Exp;
🚨 Note: Users must use a
key
prop with a unique value to render helper components in the correct order in the custom wrapper components.Affected Components;
The text was updated successfully, but these errors were encountered: