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 Dynamic Row defect #1932

Closed
jtuchel opened this issue Dec 28, 2021 · 2 comments
Closed

DataTable Dynamic Row defect #1932

jtuchel opened this issue Dec 28, 2021 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@jtuchel
Copy link

jtuchel commented Dec 28, 2021

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

This issue might be related to


Current behavior
When using this component code everything works fine

<template>
  <p-data-table>
    <p-column-group type="header">
      <p-row>
        <p-column header="Section 1" :rowspan="2" :colspan="1" />
        <p-column header="Section 2" :rowspan="1" :colspan="2" />
      </p-row>
      <p-row>
        <p-column header="Section 2.1" :rowspan="1" :colspan="1" />
        <p-column header="Section 2.2" :rowspan="1" :colspan="1" />
      </p-row>
    </p-column-group>
  </p-data-table>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import Row from "primevue/row";
import ColumnGroup from "primevue/columngroup";

export default defineComponent({
  components: {
    "p-data-table": DataTable,
    "p-column": Column,
    "p-row": Row,
    "p-column-group": ColumnGroup,
  },
});
</script>

The generated output is as expected

grafik

When using this component code instead

<template>
  <p-data-table>
    <p-column-group type="header">
      <p-row
        v-for="(row, rowIndex) in tableConfiguration"
        :key="`row-${rowIndex}`"
      >
        <p-column
          v-for="(column, columnIndex) in row"
          :key="`column-${columnIndex}`"
          :header="column.header"
          :colspan="column.colspan"
          :rowspan="column.rowspan"
        />
      </p-row>
    </p-column-group>
  </p-data-table>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import Row from "primevue/row";
import ColumnGroup from "primevue/columngroup";

export default defineComponent({
  components: {
    "p-data-table": DataTable,
    "p-column": Column,
    "p-row": Row,
    "p-column-group": ColumnGroup,
  },
  setup() {
    const tableConfiguration = ref([
      [
        {
          header: "Section 1",
          colspan: 1,
          rowspan: 2,
        },
        {
          header: "Section 2",
          colspan: 2,
          rowspan: 1,
        },
      ],
      [
        {
          header: "Section 2.1",
          colspan: 1,
          rowspan: 1,
        },
        {
          header: "Section 2.2",
          colspan: 1,
          rowspan: 1,
        },
      ],
    ]);

    return { tableConfiguration };
  },
});
</script>

I get no error but an empty table header

grafik

Expected behavior
It should render the same table

Minimal reproduction of the problem with instructions
Setup a Vue project with PrimeVue and PrimeFlex and use the component posted above.

Please tell us about your environment:
OS: Windows
Browser: Chrome
IDE: Visual Studio Code
Package manager: npm

Vue version: ^3.0.0

PrimeVue version: ^3.10.0

@mitow7821
Copy link

@tugcekucukoglu tugcekucukoglu changed the title Creating table header columns via loop renders empty table DataTable dynamic row Jan 20, 2022
@JoramM
Copy link

JoramM commented Jan 25, 2022

Jep. Same here also with PrimeVue v3.11.0.

There is nothing shown with this code:

<ColumnGroup ...>
  <Row v-for="(total, idx) in totals" :key="idx">
    <Column ... />
    <Column ... />
  </Row>
</ColumnGroup>

@tugcekucukoglu tugcekucukoglu changed the title DataTable dynamic row DataTable Dynamic Row defect Jan 26, 2022
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working vue2-portable labels Jan 26, 2022
@tugcekucukoglu tugcekucukoglu added this to the 3.11.1 milestone Jan 26, 2022
@tugcekucukoglu tugcekucukoglu self-assigned this Jan 26, 2022
tugcekucukoglu added a commit to tugcekucukoglu/primevue that referenced this issue Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants