primeng icon indicating copy to clipboard operation
primeng copied to clipboard

datatable doesn't show the data

Open uroti opened this issue 9 years ago • 3 comments

Hi to all, I created a simple table to understand PrimeNG library. The problem is that the table creates the correct number of rows but doesn't show the data inside the cells. What is the problem?

export interface User{

    username;
    name;
    surname;
    email;
}
export class TabComponent implements OnInit {


  users : User[];
  

  constructor() {

    this.users= [
      {
        "username": "Ethel Price",
        "name": "female",
        "surname": "Johnson, Johnson and Partners, LLC CMP DDC",
        "email": "22"
      },
      {
        "username": "Ethel Price",
        "name": "female",
        "surname": "Johnson, Johnson and Partners, LLC CMP DDC",
        "email": "22"
      },
      {
        "username": "Ethel Price",
        "name": "female",
        "surname": "Johnson, Johnson and Partners, LLC CMP DDC",
        "email": "22"
      }];

  }
<p-dataTable [value]="users"  >
 
  <p-column field="Username" header="Username"></p-column>
  <p-column field="Name" header="Name"></p-column>
  <p-column field="Surname" header="Surname"></p-column>
  <p-column field="Email" header="Email"></p-column>
</p-dataTable>

uroti avatar Mar 27 '17 09:03 uroti

Check your field values in the HTML. It should be the name of the attribute.

<p-column field="username" header="Username"></p-column>

You wrote all of them with Uppercase first letter.

UCKFA avatar Mar 27 '17 09:03 UCKFA

Yes, thank you, a stupid error!

uroti avatar Mar 27 '17 09:03 uroti

Please use forum in future for cases like these;

https://forum.primefaces.org/viewforum.php?f=35

cagataycivici avatar Mar 27 '17 11:03 cagataycivici