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 template and expandable rows #1396

Closed
tigrenok00 opened this issue Nov 22, 2016 · 6 comments
Closed

Datatable column template and expandable rows #1396

tigrenok00 opened this issue Nov 22, 2016 · 6 comments
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@tigrenok00
Copy link

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior

Hi

I have a table with expandable rows, the expansion template displays an inner table.
Everything works perfectly, including the expansion, until I add a column template to the outer table - see column "custPrice".
It the custPrice row is displayed correctly, incuding the value, but when I click to expand the row - I get the following error:

EXCEPTION: Error in ./PlanDataComponent class PlanDataComponent - inline template:169:61 caused by: Cannot read property 'custPrice' of undefined

<p-dataTable [value]="planData.custLvl" class="small" expandableRows="true" tableStyleClass="my-table" [editable]="true">
          <p-column expander="true" styleClass="col-icon"></p-column>
          <p-column field="element.text" header=" " styleClass="col-item"></p-column>
          <p-column field="netPrice" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="discountPct" header="xxx" styleClass="row-regular-editable">
          </p-column>
          <p-column field="custPrice" header="xxx" styleClass="row-regular-editable">
           <template let-el1="rowData" pTemplate type="body">
                 {{el1.custPrice}}
            </template>
          </p-column>
          <p-column field="posPrice" header="xxx" styleClass="row-regular-editable" [editable]="true"></p-column>
          <p-column field="baseFcst" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="upliftPct" header="xxx" styleClass="row-regular-editable" [editable]="true"></p-column>
          <p-column field="upliftUnit" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="totalFcst" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="plnCost" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="startDate" header="xxx" styleClass="row-regular"></p-column>
          <p-column field="endDate" header="xxx" styleClass="row-regular"></p-column>

         <template let-cust>
            <p-dataTable [value]="cust.items" tableStyleClass="inner-table" [editable]="true">
              <p-column field="element.text" header=" " styleClass="col-item-inner"></p-column>
              <p-column field="netPrice" header="xxx" styleClass="row-inner"></p-column>
              <p-column field="discountPct" header="xxx" styleClass="row-inner-editable"></p-column>
              <p-column field="custPrice" header="xxx" styleClass="row-inner-editable" [editable]="true"></p-column>
              <p-column field="posPrice" header="xxx" styleClass="row-inner-editable" [editable]="true"></p-column>
              <p-column field="baseFcst" header="xxx" styleClass="row-inner"></p-column>
              <p-column field="upliftPct" header="xxx" styleClass="row-inner-editable" [editable]="true"></p-column>
              <p-column field="upliftUnit" header="xxx'" styleClass="row-inner"></p-column>
              <p-column field="totalFcst" header="xxx" styleClass="row-inner"></p-column>
              <p-column field="plnCost" header="xxx" styleClass="row-inner"></p-column>
              <p-column field="startDate" header="xxx" styleClass="row-inner-editable" [editable]="true"></p-column>
              <p-column field="endDate" header="xxx" styleClass="row-inner-editable" [editable]="true"></p-column>
            </p-dataTable>
          </template>

        </p-dataTable>
  • Angular version: 2.0.X
    ~2.1.0

  • PrimeNG version: 2.0.X
    1.0.0-rc.4

  • Browser: [all]

@ribizli
Copy link

ribizli commented Nov 22, 2016

This is still the same issue from #966.
See also #1366 for an other strange problem.

@cagataycivici
Copy link
Member

You need to use;

{code}
<p-dataTable [value]="planData.custLvl" class="small" expandableRows="true" tableStyleClass="my-table" [editable]="true">

<p-dataTable [value]="cust.items" tableStyleClass="inner-table" [editable]="true">



<p-column field="custPrice" header="xxx" styleClass="row-inner-editable" [editable]="true">
<p-column field="posPrice" header="xxx" styleClass="row-inner-editable" [editable]="true">

<p-column field="upliftPct" header="xxx" styleClass="row-inner-editable" [editable]="true">



<p-column field="startDate" header="xxx" styleClass="row-inner-editable" [editable]="true">
<p-column field="endDate" header="xxx" styleClass="row-inner-editable" [editable]="true">

      <p-column expander="true" styleClass="col-icon"></p-column>
      <p-column field="element.text" header=" " styleClass="col-item"></p-column>
      <p-column field="netPrice" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="discountPct" header="xxx" styleClass="row-regular-editable">
      </p-column>
      <p-column field="custPrice" header="xxx" styleClass="row-regular-editable">
       <template let-el1="rowData" pTemplate type="body">
             {{el1.custPrice}}
        </template>
      </p-column>
      <p-column field="posPrice" header="xxx" styleClass="row-regular-editable" [editable]="true"></p-column>
      <p-column field="baseFcst" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="upliftPct" header="xxx" styleClass="row-regular-editable" [editable]="true"></p-column>
      <p-column field="upliftUnit" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="totalFcst" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="plnCost" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="startDate" header="xxx" styleClass="row-regular"></p-column>
      <p-column field="endDate" header="xxx" styleClass="row-regular"></p-column>

    </p-dataTable>

{code}

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Nov 22, 2016
@cagataycivici cagataycivici added this to the 1.0.1 milestone Nov 22, 2016
@cagataycivici
Copy link
Member

Location does not matter in 1.0 final though.

@tigrenok00
Copy link
Author

Awesome, thanks a lot

@ribizli
Copy link

ribizli commented Nov 22, 2016

With your current solution (which I haven't tested btw) you take the first child, so location indeed matters.

@ilianiv
Copy link

ilianiv commented Nov 22, 2016

I am afraid of this, too 7b20941#commitcomment-19920597

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