2017-08-02 3 views
3

erreur TypeError:question Tableau de données - erreur TypeError: val.slice est pas une fonction

val.slice is not a function

configuration dataTable

$.p-dataTable #dt [value]="customers" [(selection)]="chkBoxSelect" 
dataKey="customerId" [rows]="10" [paginator]="true" 
paginatorPosition="both" [pageLinks]="5" [rowsPerPageOptions]="[5,10,20]" 
[globalFilter]="gb" [headerCheckboxToggleAllPages]="false" 
[editable]="true" exportFilename="customers" [lazy]="true" 
[totalRecords]="totalRecords" onLazyLoad)="loadCustomersByPage($event)" 

call back

$loadCustomersByPage(event: LazyLoadEvent) { 

    const parameters = "?page=" + event.first + "&size=" + (event.first + event.rows); 

    this._cs.findAllActiveCustomerDetailsByPage(parameters).subscribe(
     (data: any) => { 
     this.customers = data; 
     }, 
     (error) => { 
      console.log("--error--" + error) 
     } 
); 
} 
+3

Mon problème résolu . c'etait mon erreur. les données n'étaient pas l'objet approprié – Hari

+0

pouvez-vous s'il vous plaît fournir le bon type d'objet? – DenisK

Répondre

1

On dirait que les données ne sont pas formatées correctement ..

Voici comment votre objet de données attribué à la table devrait ressembler à:

let cars = [ 
    {"brand": "VW", "year": 2012, "color": "Orange", "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": "Orange", "vin": "hrtwy34"}, 
    {"brand": "Volvo", "year": 2005, "color": "Black", "vin": "jejtyj"}, 
    {"brand": "Honda", "year": 2012, "color": "Yellow", "vin": "g43gr"}, 
    {"brand": "Jaguar", "year": 2013, "color": "Orange", "vin": "greg34"}, 
    {"brand": "Ford", "year": 2000, "color": "Black", "vin": "h54hw5"}, 
    {"brand": "Fiat", "year": 2013, "color": "Red", "vin": "245t2s"} 
] 
0

Si vous attendez des données JSON-formated, comprennent la méthode .json():

this._cs.findAllActiveCustomerDetailsByPage(parameters).subscribe(
     (data: any) => { 
     this.customers = data.json(); 
     },`enter code here`