Data table can not be generated

UI Components for Angular
Post Reply
kumawat
Posts: 27
Joined: 11 Mar 2016, 15:26

12 Mar 2016, 18:25

Hello Prime,

I have started using your library for datatable.

Import {Column} from 'primeng/primeng' is missing from library. I have seen in the package it exists but under api/column.

when i try to generate data table like this, (without values for RowData)

<p-dataTable name="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>


It failed and giving me execpetion for Hasfooter in DataTable.ts file. [Exeception : Cannot read property 'length' of undefined in [hasFooter() in DataTable@29:27]

Please suggest me what is wrong over here. I didn't get it work for simple layout. :?:

vittorio
Posts: 10
Joined: 11 Mar 2016, 16:13

12 Mar 2016, 18:36

i think it's because the column in the api folder is just an interface whilst the column should be an angular component to replace the "p-column" selector tag.

primeng\components\api\column.d.ts

Code: Select all

export interface Column {
    field: any;
    header?: any;
    footer?: any;
    sortable?: any;
    editable?: any;
    filter?: any;
    filterMatchMode?: any;
    rowspan?: any;
    colspan?: any;
    style?: any;
    styleClass?: any;
}
column class @github
https://github.com/primefaces/primeng/b ... /column.ts

As i see from github project page, the column calss will be avaible in v0.7

PS: a simple workaround i'm using

html template

Code: Select all

<p-dataTable    [value]="my_data" 
                        [columns]="my_cols"
</p-dataTable>
.ts component

Code: Select all

import { Column } from  'primeng/components/api/column';
@Component
({
	selector: 'my-table',
	templateUrl: "path/to/my/template.html",
	directives: [ DataTable ]
})
export class AppComponent 
{
    my_data: MyDataObject[];
    my_cols: Column [];

    constructor() { }

    ngOnInit() 
    {
        this.cols = [
            {field: 'col1', header: 'Column 1' },
            {field: "col2", header: "Column 2" } ];
    }

}

kumawat
Posts: 27
Joined: 11 Mar 2016, 15:26

12 Mar 2016, 19:17

Hi Vittorio,

Thank you for the input.

It indeed helped me with the Data table generation problem. Thank you for your quick help. :)

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

12 Mar 2016, 22:58

Please note that the live showcase runs on 0.7-SNAPSHOT that introduced the Column as a component, as of 0.6, it is an interface. With 0.7 columns are defined using p-column elements instead of columns property which is removed. The gain is major though which is the ability to place custom content in cells;

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

This is a breaking change for 0.7 that comes out on 14th, monday.

vittorio
Posts: 10
Joined: 11 Mar 2016, 16:13

13 Mar 2016, 10:16

optimus.prime wrote: This is a breaking change for 0.7 that comes out on 14th, monday.
Wow, nice! :D

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

14 Mar 2016, 09:27

Good morning,

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, 11:27

Could you please create a new post to track it better?


Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests