Datatable fails to render after upgrading to PrimeNG 0.7

UI Components for Angular
TekSiDoT
Posts: 32
Joined: 10 Mar 2016, 16:44

14 Mar 2016, 11:35

PrimeNG 0.7 as of this morning fails to display data after restructuring to the new column component format:

Excerpt from the array of columns:

Code: Select all

0: Column
editable: false
field: "name"
header: "Name"
sortable: false
__proto__: Column
1: Column
editable: true
field: "type"
header: "Type"
sortable: true
__proto__: Column
2: Column
editable: true
field: "activated"
header: "Activate Limit"
sortable: true
__proto__: Column
(and so on) 
component:

Code: Select all

import { Component, OnInit } from "angular2/core";
import { DataTable, Column } from "primeng/primeng";
import { XmlService } from "./xml.service";

@Component({
    selector: "limit-limits",
/*    template: `
        <h1>Limits</h1>
        <p-dataTable [(value)]="limitsData" [columns]="limitsCols" [editable]="true">    
        </p-dataTable>
    `,*/
    
    template: `
    <h1>Limits</h1>
    <p-dataTable [value]="limitsData">
    <p-column *ngFor="#col of limitsCols" [field]="col.field" [header]="col.header"></p-column>
    </p-dataTable>`, 
    
    directives: [DataTable],
    providers: [XmlService],
})

export class LimitsComponent implements OnInit {
  
    limitsData: any[] = [];
    limitsCols: Column[] = []; 

(continues to generate data) 

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2016, 12:02

What is the error you are getting? So dynamic columns with ngFor works but defining columns one by one with p:column fails?

TekSiDoT
Posts: 32
Joined: 10 Mar 2016, 16:44

14 Mar 2016, 12:12

Before tonights update I was succesfully using dynamic column generation with a custom Column interface import.

As of this morning, the following attempts have been unsuccesful:

* Dynamic column creation based on [columns] and using the column interface
* Dynamic column creation based on *ngFor and using the new column object (the sample code in the first post)


There is no error message, the table silently fails to render.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2016, 12:17

Ok, thanks.
* Dynamic column creation based on [columns] and using the column interface
This is expected, columns property is removed in favor *ngFor on p:column
* Dynamic column creation based on *ngFor and using the new column object (the sample code in the first post)
I'll test in a minute.

Does the static version work?

Code: Select all

<p-dataTable [value]="cars">
    <p-column field="vin" header="Vin"></p-column>
    <p-column field="year" header="Year"></p-column>
    <p-column field="brand" header="Brand"></p-column>
    <p-column field="color" header="Color"></p-column>
</p-dataTable>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2016, 12:22

It worked for me using showcase code;

Code: Select all

export class DataTableDemo implements OnInit {

    cars: Car[];
    
    cols: any[];
    
    constructor(private carService: CarService) { }

    ngOnInit() {
        this.carService.getCarsSmall().then(cars => this.cars = cars);
        
        this.cols = [
            {field: 'vin', header: 'Vin'},
            {field: 'year', header: 'Year'},
            {field: 'color', header: 'Color'}
        ];
    }
}

Code: Select all

    <p-dataTable [value]="cars">
    <p-column *ngFor="#col of cols" [field]="col.field" [header]="col.header"></p-column>
</p-dataTable>
Are you on angular2 beta 9?

TekSiDoT
Posts: 32
Joined: 10 Mar 2016, 16:44

14 Mar 2016, 12:28

Interesting, static creation fails as well.

template:

Code: Select all

    
<h1>Limits</h1>
    <p-dataTable [value]="limitsData">    
    <p-column field="name" header="Name"></p-column>
    <p-column field="type" header="Type"></p-column>
    </p-dataTable>
limitsData Array (contrived):

Code: Select all

[Array[0]]
0: Array[0]
activated: "true"
bandwidth: "210"
centerValue: "2100"
checkIt: "true"
length: 0
name: "Limit1"
type: "Frequency Limit"
Are you on angular2 beta 9?
Affirm.

Considering the basic static display stopped working as well, I'll check using the basic showcase example and get back to you.

TekSiDoT
Posts: 32
Joined: 10 Mar 2016, 16:44

14 Mar 2016, 14:50

First, I downloaded and npm installed the primeng-master branch and its dependencies -> All showcases runs smoothly.

I tried to mirror the dependencies of this primeNG and the respective versions to my old app -> no luck.

Trying to reproduce the running behavior of the showcase examples in a green-field-app -> no luck.


This is the complete app:

Code: Select all

import { Component, OnInit, OnChanges } from "angular2/core";
import { DataTable } from "primeng/primeng";

@Component({
    selector: "ng-limit",
    template: `<h3 class="first">Basic</h3>
    <p-dataTable [value]="cars">
        <p-column field="vin" header="Vin"></p-column>
        <p-column field="year" header="Year"></p-column>
        <p-column field="brand" header="Brand"></p-column>
        <p-column field="color" header="Color"></p-column>
    </p-dataTable>
    
    <h3>Dynamic Columns</h3>
    <p-dataTable [value]="cars">
        <p-column *ngFor="#col of cols" [field]="col.field" [header]="col.header"></p-column>
    </p-dataTable>`,
    directives: [DataTable]
})

export class AppComponent implements OnInit {
    
    private cols:any[];
    private cars:any[];    
    
    constructor() { 
            
        }
               
    ngOnInit() {
        
        this.cols = [
            {field: 'vin', header: 'Vin'},
            {field: 'year', header: 'Year'},
            {field: 'brand', header: 'Brand'},
            {field: 'color', header: 'Color'}
        ];
                
        this.cars = [
        {"brand": "VW", "year": 2012, "color": "White", "vin": "dsad231ff"},
        {"brand": "Audi", "year": 2011, "color": "Black", "vin": "gwregre345"},
        {"brand": "Renault", "year": 2005, "color": "Gray", "vin": "h354htr"},
        {"brand": "BMW", "year": 2003, "color": "Blue", "vin": "j6w54qgh"},
        {"brand": "Mercedes", "year": 1995, "color": "White", "vin": "hrtwy34"},
        {"brand": "Volvo", "year": 2005, "color": "Black", "vin": "jejtyj"},
        {"brand": "Honda", "year": 2012, "color": "Yellow", "vin": "g43gr"},
        {"brand": "Jaguar", "year": 2013, "color": "White", "vin": "greg34"},
        {"brand": "Ford", "year": 2000, "color": "Black", "vin": "h54hw5"},
        {"brand": "Fiat", "year": 2013, "color": "Red", "vin": "245t2s"}
    ]

    }
}
Here are my relevant configuration files:

package.json:

Code: Select all

{
  "name": "grd",
  "version": "1.0.0",
  "description": "lets try that again",
  "main": "index.js",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "license": "Apache-2.0",
  "peerDependencies": {
    "angular2": ">=2.0.0-beta.9",
    "systemjs": ">=0.19.24",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": ">=5.0.0-beta.2",
    "zone.js": "0.5.15",
    "primeng": "0.7.0"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.8.7",
    "typings": "^0.7.5",
    "zone.js": "^0.5.15"
  },
  "dependencies": {
    "primeui": "^4.1.3"
  }
}
tsconfig.json:

Code: Select all

{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "outDir": "./",
        "rootDir": "src"
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
typings.json:

Code: Select all

{
    "ambientDependencies": {
        "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2",
        "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#470954c4f427e0805a2d633636a7c6aa7170def8"
    }
}
and for good measure the index.html:

Code: Select all

<html>

  <head>
    <title>limitProcNG</title>

    <link rel="stylesheet" type="text/css" href="app/resources/delta/theme.css" />
    <link rel="stylesheet" type="text/css" href="app/resources/icons/css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="app/resources/primeui.css" />

    <!-- 1. Load libraries -->
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="../node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script src="app/resources/jquery.js"></script>
    <script src="app/resources/jquery-ui.js"></script>
    <script src="app/resources/primeui.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          'primeng': 'node_modules/primeng'
        },
        map: {
            'primeng': 'node_modules/primeng',
            'rxjs':"lib/rxjs"            
        }        
      });        
        
      System.import('app/boot').then(null, console.error.bind(console));
    </script>
    
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.js"></script>

  </head>

  <!-- 3. Display the application -->
  <body>
    <ng-limit>Loading...</ng-limit>
  </body>

</html>
I have a bad feeling that this is some stupid mistake on my end.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2016, 16:03

I think I got it, also import Column component and configure at directives section;

Code: Select all

import { Component, OnInit, OnChanges } from "angular2/core";
import {DataTable} from "primeng/primeng";
import {Column} from "primeng/primeng";

@Component({
    selector: "ng-limit",
    template: `<h3 class="first">Basic</h3>
    <p-dataTable [value]="cars">
        <p-column field="vin" header="Vin"></p-column>
        <p-column field="year" header="Year"></p-column>
        <p-column field="brand" header="Brand"></p-column>
        <p-column field="color" header="Color"></p-column>
    </p-dataTable>
    
    <h3>Dynamic Columns</h3>
    <p-dataTable [value]="cars">
        <p-column *ngFor="#col of cols" [field]="col.field" [header]="col.header"></p-column>
    </p-dataTable>`,
    directives: [DataTable,Column]
})

export class AppComponent implements OnInit {
    
    private cols:any[];
    private cars:any[];    
    
    constructor() { 
            
        }
               
    ngOnInit() {
        
        this.cols = [
            {field: 'vin', header: 'Vin'},
            {field: 'year', header: 'Year'},
            {field: 'brand', header: 'Brand'},
            {field: 'color', header: 'Color'}
        ];
                
        this.cars = [
        {"brand": "VW", "year": 2012, "color": "White", "vin": "dsad231ff"},
        {"brand": "Audi", "year": 2011, "color": "Black", "vin": "gwregre345"},
        {"brand": "Renault", "year": 2005, "color": "Gray", "vin": "h354htr"},
        {"brand": "BMW", "year": 2003, "color": "Blue", "vin": "j6w54qgh"},
        {"brand": "Mercedes", "year": 1995, "color": "White", "vin": "hrtwy34"},
        {"brand": "Volvo", "year": 2005, "color": "Black", "vin": "jejtyj"},
        {"brand": "Honda", "year": 2012, "color": "Yellow", "vin": "g43gr"},
        {"brand": "Jaguar", "year": 2013, "color": "White", "vin": "greg34"},
        {"brand": "Ford", "year": 2000, "color": "Black", "vin": "h54hw5"},
        {"brand": "Fiat", "year": 2013, "color": "Red", "vin": "245t2s"}
    ]

    }
}

TekSiDoT
Posts: 32
Joined: 10 Mar 2016, 16:44

14 Mar 2016, 16:10

Halleluja, we're back. Works like a charm, thanks Optimus!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2016, 16:12

Glad to hear!

Also if you install primeui from npm, we've added optimized bundles for PrimeUI called primeui-ng-all files.

So your head section could be simplified as follows;

Code: Select all

<head>
    <title>limitProcNG</title>

    <link rel="stylesheet" type="text/css" href="node_modules/primeui/themes/bootstrap/theme.css" />
    <link rel="stylesheet" type="text/css" href="app/resources/icons/css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="node_modules/primeui/primeui-ng-all.min.css" />

    <!-- 1. Load libraries -->
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="../node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script src="node_modules/primeui/primeui-ng-all.min.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          'primeng': 'node_modules/primeng'
        },
        map: {
            'primeng': 'node_modules/primeng',
            'rxjs':"lib/rxjs"            
        }        
      });        
        
      System.import('app/boot').then(null, console.error.bind(console));
    </script>
    
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.js"></script>

  </head>
More info at;

http://www.primefaces.org/primeng/#/setup

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests