1
votes

I am using primeng in my angular2 application. I am using DataTable for my table view and when I try to do checkbox with paging as explained in HERE I am getting errors...

Error ...

Unhandled Promise rejection: Template parse errors:
Can't bind to 'headerCheckboxToggleAllPages' since it isn't a known property of 'p-dataTable'.
1. If 'p-dataTable' is an Angular component and it has 'headerCheckboxToggleAllPages' input, then verify that it is part of this module.
2. If 'p-dataTable' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. [ERROR ->][headerCheckboxToggleAllPages]="true">
  <p-col"): ViewProductsComponent@22:36 ; Zone: <root> ; Task: Promise.then ; Value: SyntaxError Error: Template parse errors:

Do I need to import any specific module for this as the documentation doesn't say on imports and I had similar issue HEREand after importing the modules it worked.

Here is my view.html

<p-dataTable [value]="cars" [(selection)]="selectedCars3" [paginator]="true" [rows]="5" [headerCheckboxToggleAllPages]="true" sortMode="multiple" [selectionMode]="userRole=='user'? 'none' : 'single' ">
    <p-header>Checkbox Multiple Selection with Paging</p-header>
    <p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
    <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-footer>
        <ul>
            <li *ngFor="let car of selectedCars3" style="text-align: left">{{car.vin + ' - ' + car.brand + ' - ' + car.year + ' - ' + car.color}}</li>
        </ul>
    </p-footer>
</p-dataTable>

and @NgModule.imports are ...

imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
routing,
DropdownModule,
DataTableModule,
DialogModule,
ConfirmDialogModule,
ContextMenuModule,
PanelModule,
OverlayPanelModule,
PanelMenuModule,
GrowlModule,
FileUploadModule,
InputSwitchModule,
TreeTableModule,
SharedModule,
CalendarModule,
ClipboardModule,
CommonModule,
SpinnerModule.forRoot(),
TabViewModule,
AutoCompleteModule
]

My package.json dependencies ...

"dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "primeng": "^2.0.1",
    "rxjs": "^5.0.1"
}

I also tried with pprimeng:4.1.0-rc.2 got same issue. Please suggest. Thanks

2
with 4.1.0 same error?alehn96

2 Answers

1
votes

You must import

import {DataTableModule,SharedModule} from 'primeng/primeng';

and register in @NgModule.imports

0
votes

It is not clear what could be the reason behind the error But to you can make sure certain things like -

If you are changing version in package.json, To reflect version change, you must run command

npm install

After updating dependencies, one can confirm if certain property is present or not for a component by looking into it's definition file. for example look for 'headerCheckboxToggleAllPages' in

node_modules\primeng\components\datatable\datatable.d.ts

Hope this helps.