title: PrimeNG datatable checkbox selection with pagination
body: <p>I'm trying to bring a data table layout with pagination that has checkbox selection for data in it. I'm able to select a page's data and when I move to another page, and select different set of data, the first page selection is lost. </p>
  
  <p>demo.html:
      </p>
  
  <pre><code>    &lt;p-dataTable [value]="cars" [rows]="10" [paginator]="true" [pageLinks]="3" [rowsPerPageOptions]="[5,10,20]" sortMode="multiple" [(selection)]="selectedCars2"&gt;
          &lt;p-column [style]="{'width':'38px'}" selectionMode="multiple" &gt;&lt;/p-column&gt;
          &lt;p-column field="vin" header="Vin"&gt;&lt;/p-column&gt;
          &lt;p-column field="year" header="Year"&gt;&lt;/p-column&gt;
          &lt;p-column field="brand" header="Brand"&gt;&lt;/p-column&gt;
          &lt;p-column field="color" header="Color"&gt;
              &lt;template let-col let-car="rowData" pTemplate type="body"&gt;
                  &lt;span [style.color]="car[col.field]"&gt;{{car[col.field]}}&lt;/span&gt;
              &lt;/template&gt;
          &lt;/p-column&gt;
  
          &lt;!--&lt;p-column styleClass="col-button"&gt;
              &lt;template pTemplate type="header"&gt;
                  &lt;input type="checkbox" [(ngModel)]="checkUncheckAll" /&gt;
              &lt;/template&gt;
              &lt;template let-car="rowData" pTemplate type="body"&gt;
                  &lt;input type="checkbox" [(ngModel)]="checkValue[car.vin]" (click)="selectCar(car, checkValue[car.vin])"/&gt;
              &lt;/template&gt;
          &lt;/p-column&gt;--&gt;
      &lt;/p-dataTable&gt;
  
      &lt;div class="table-controls-top"&gt;&lt;div class="pager"&gt;&lt;input type="button" class="button_tablecontrol" (click)="selectCar(selectedCars2)" value="Delete"&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>demo.ts:</p>
  
  <pre><code>import {Component,OnInit} from '@angular/core';
  import {Car} from '../domain/car';
  import {CarService} from '../service/carservice';
  import {Message} from '../common/api';
  
  @Component({
      templateUrl: 'app/showcase/demo/datatable/datatabledemo.html'
  })
  export class DataTableDemo implements OnInit {
  
      cars: Car[];
  
      cols: any[];
  
      msgs: Message[] = [];
  
      checkValue: any;
  
      selectedCars2: any[];
  
      constructor(private carService: CarService) { 
  
          this.checkValue = {};
  
          this.selectedCars2 = [];
  
      }
  
      ngOnInit() {
          this.carService.getCarsCustom().then(
          cars =&gt; {
              this.cars = cars;
              for (var car of this.cars) {
              console.log(car.vin)
                  this.checkValue[car.vin] = false;
              }
          });
  
          this.cols = [
              {field: 'vin', header: 'Vin'},
              {field: 'year', header: 'Year'},
              {field: 'brand', header: 'Brand'},
              {field: 'color', header: 'Color'}
          ];
      }
  
      selectCar(selectedCars) {
  
          console.log(selectedCars)
          console.log(this.selectedCars2)
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TUkdV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TUkdV.png" alt="Screenshot of datatable"></a></p>
  
  <p>I suppose the team hasn't implemented the functionality yet. Any idea/insights on how to retain the selection of rows (in model 'selectedCars2') with pagination?</p>
  
  <p>Thanks in advance.</p>